feat: update Docker configuration

Removed version specification from docker-compose.yml and added mysqli extension installation in Dockerfile.
This commit is contained in:
2025-09-26 01:01:44 -03:00
parent bf12e00572
commit 0cd48261f4
10 changed files with 562 additions and 2 deletions

View File

@@ -0,0 +1,83 @@
# Dockerfile for a generic Laravel 10 environment
# with Official Microsoft SQL Server Drivers (sqlsrv, pdo_sqlsrv)
# 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
# Accept the EULA for the Microsoft ODBC driver
ENV ACCEPT_EULA=Y
# 1. Install System Dependencies
# This section installs the official Microsoft ODBC Driver 17 for SQL Server.
RUN apt-get update && \
apt-get install -y \
# Common tools
git \
curl \
zip \
unzip \
gnupg \
ca-certificates \
apt-transport-https \
# Dependencies for PECL and PHP extensions
libpng-dev \
libxml2-dev \
libzip-dev \
libonig-dev \
build-essential \
unixodbc-dev && \
# Add Microsoft's official repository for Debian 12 (Bookworm)
# This is the corrected method to handle the GPG key securely.
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /etc/apt/keyrings/microsoft.gpg && \
chmod 644 /etc/apt/keyrings/microsoft.gpg && \
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/debian/12/prod bookworm main" | tee /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
# Install the ODBC driver
apt-get install -y msodbcsql17 && \
# Install Node.js (we'll use v18)
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
# This section installs the sqlsrv and pdo_sqlsrv extensions via PECL.
RUN pecl install sqlsrv pdo_sqlsrv && \
docker-php-ext-enable sqlsrv pdo_sqlsrv && \
docker-php-ext-install \
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.