add docker configuration to run local webserver and app

This commit is contained in:
Joseph D'Souza 2026-02-06 13:17:29 +01:00
parent 30433b7183
commit 22da268739
4 changed files with 98 additions and 0 deletions

41
docker-compose.yml Normal file
View File

@ -0,0 +1,41 @@
services:
# The Application Service (PHP)
app:
build:
context: ./server
dockerfile: Dockerfile
args:
- user=${USER}
- uid=${UID}
image: casadoc-app
container_name: casadoc-app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./server:/var/www
- ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
# The Web Server (Nginx)
webserver:
image: nginx:alpine
container_name: casadoc-webserver
restart: unless-stopped
tty: true
ports:
- "8000:80"
volumes:
- ./server:/var/www
- ./docker/nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
# Docker Networks
networks:
app-network:
driver: bridge

View File

@ -0,0 +1,20 @@
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}

2
docker/php/local.ini Normal file
View File

@ -0,0 +1,2 @@
upload_max_filesize=100M
post_max_size=100M

35
server/Dockerfile Normal file
View File

@ -0,0 +1,35 @@
FROM php:8.2-fpm
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
# Set working directory
WORKDIR /var/www
# Switch back to the application user
USER $user