Removed version specification from docker-compose.yml and added mysqli extension installation in Dockerfile.
77 lines
2.5 KiB
Docker
77 lines
2.5 KiB
Docker
# Dockerfile for a generic Laravel 10 environment
|
|
# with SQL Server 2008 Support (via FreeTDS)
|
|
|
|
# Use PHP 8.2 as a base image, required for Laravel 10
|
|
ARG PHP_VERSION=8.3.20
|
|
FROM php:${PHP_VERSION}-fpm
|
|
|
|
# Set arguments for user and group IDs. These can be passed during build time.
|
|
ARG LARAVEL_SAIL_USER_ID=1000
|
|
ARG LARAVEL_SAIL_GROUP_ID=1000
|
|
|
|
# Set Working Directory for the container
|
|
WORKDIR /var/www/html
|
|
|
|
# Set environment variables to prevent interactive prompts during installation
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=UTC
|
|
|
|
# 1. Install System Dependencies
|
|
# - Common tools: git, curl, zip, etc.
|
|
# - PHP extension dependencies: libpng, libxml, etc.
|
|
# - FreeTDS: The key component for connecting to SQL Server 2008 (freetds-dev, freetds-bin)
|
|
# - Node.js and npm: For running `npm run dev`
|
|
RUN apt-get update && \
|
|
apt-get install -y \
|
|
git \
|
|
curl \
|
|
zip \
|
|
unzip \
|
|
libpng-dev \
|
|
libxml2-dev \
|
|
libzip-dev \
|
|
libonig-dev \
|
|
gnupg \
|
|
ca-certificates \
|
|
# Install FreeTDS libraries
|
|
freetds-dev \
|
|
freetds-bin \
|
|
tdsodbc && \
|
|
# Install Node.js (we'll use v18)
|
|
mkdir -p /etc/apt/keyrings && \
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
|
|
NODE_MAJOR=18 && \
|
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
|
|
apt-get update && \
|
|
apt-get install -y nodejs && \
|
|
# Clean up apt cache
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# 2. Install PHP Extensions
|
|
# - We install common Laravel extensions.
|
|
# - We configure and install pdo_dblib, which uses FreeTDS to connect to SQL Server.
|
|
RUN docker-php-ext-configure pdo_dblib --with-libdir=/usr/lib/x86_64-linux-gnu && \
|
|
docker-php-ext-install \
|
|
pdo \
|
|
pdo_dblib \
|
|
bcmath \
|
|
gd \
|
|
exif \
|
|
pcntl \
|
|
zip \
|
|
mbstring
|
|
|
|
# 3. Install Composer (PHP Package Manager)
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
# 4. Create a non-root user to run the application
|
|
# This is a security best practice and helps avoid permission errors.
|
|
RUN groupadd --force -g $LARAVEL_SAIL_GROUP_ID sail && \
|
|
useradd -ms /bin/bash --no-user-group -g sail -u $LARAVEL_SAIL_USER_ID sail
|
|
|
|
# 5. Switch to the non-root user
|
|
USER sail
|
|
|
|
# The image build process stops here. The working directory is set to /var/www/html.
|
|
# When you use this image, you will mount your project code into this directory. |