diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..69179c7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,22 @@ +.git +.gitignore +.env +vendor +node_modules +storage/logs/* +storage/framework/cache/* +storage/framework/sessions/* +storage/framework/views/* +bootstrap/cache/* +public/build +public/storage +db_data +redis_data +docker-compose.yml +docker-compose.override.yml +README.md +TerManager2_v2.md +.idea +.vscode +*.swp +*.swo diff --git a/docker-compose.yml b/docker-compose.yml index 1819a03..7af3b57 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,13 @@ services: app: build: - context: ./docker/php + context: . + dockerfile: docker/php/Dockerfile container_name: termanager2_app restart: unless-stopped working_dir: /var/www/html volumes: - - .:/var/www/html + - app_code:/var/www/html - storage_data:/var/www/html/storage/app networks: - termanager2 @@ -19,14 +20,15 @@ services: - PHP_OPCACHE_VALIDATE_TIMESTAMPS=1 nginx: - image: nginx:1.25-alpine + build: + context: . + dockerfile: docker/nginx/Dockerfile container_name: termanager2_nginx restart: unless-stopped ports: - "${APP_PORT:-8080}:80" volumes: - - .:/var/www/html:ro - - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro + - app_code:/var/www/html:ro networks: - termanager2 depends_on: @@ -81,6 +83,8 @@ services: - termanager2 volumes: + app_code: + driver: local db_data: driver: local redis_data: diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 0000000..cd6b871 --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:1.25-alpine +COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 062cee4..1c26448 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -42,14 +42,17 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ # Set working directory WORKDIR /var/www/html +# Copy application code to staging area +COPY . /app-src/ + # Copy PHP configuration -COPY php.ini /usr/local/etc/php/conf.d/custom.ini +COPY docker/php/php.ini /usr/local/etc/php/conf.d/custom.ini # Copy PHP-FPM pool config -COPY www.conf /usr/local/etc/php-fpm.d/www.conf +COPY docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf # Copy entrypoint -COPY entrypoint.sh /usr/local/bin/entrypoint.sh +COPY docker/php/entrypoint.sh /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh EXPOSE 9000 diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh index 8a7231c..86a1839 100755 --- a/docker/php/entrypoint.sh +++ b/docker/php/entrypoint.sh @@ -6,7 +6,17 @@ echo " TerManager2 - Entrypoint" echo "=========================================" # ----------------------------------------------- -# 0. Create required directories +# 0. Sync application code from image to volume +# ----------------------------------------------- +if [ ! -f /var/www/html/artisan ]; then + echo "[*] Syncing application code to volume..." + cp -a /app-src/. /var/www/html/ +else + echo "[✓] Application code already in volume." +fi + +# ----------------------------------------------- +# 0b. Create required directories # ----------------------------------------------- mkdir -p storage/framework/{cache,sessions,views} mkdir -p storage/logs