Restructure Docker for Dokploy deployment
- Copy app code into PHP image, sync to shared volume at startup - Use named volume (app_code) shared between app and nginx - Build nginx image with embedded config (no bind mounts) - Add .dockerignore to optimize image build - Build context moved to project root for both services
This commit is contained in:
22
.dockerignore
Normal file
22
.dockerignore
Normal file
@@ -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
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: ./docker/php
|
context: .
|
||||||
|
dockerfile: docker/php/Dockerfile
|
||||||
container_name: termanager2_app
|
container_name: termanager2_app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
working_dir: /var/www/html
|
working_dir: /var/www/html
|
||||||
volumes:
|
volumes:
|
||||||
- .:/var/www/html
|
- app_code:/var/www/html
|
||||||
- storage_data:/var/www/html/storage/app
|
- storage_data:/var/www/html/storage/app
|
||||||
networks:
|
networks:
|
||||||
- termanager2
|
- termanager2
|
||||||
@@ -19,14 +20,15 @@ services:
|
|||||||
- PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
|
- PHP_OPCACHE_VALIDATE_TIMESTAMPS=1
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:1.25-alpine
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/nginx/Dockerfile
|
||||||
container_name: termanager2_nginx
|
container_name: termanager2_nginx
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "${APP_PORT:-8080}:80"
|
- "${APP_PORT:-8080}:80"
|
||||||
volumes:
|
volumes:
|
||||||
- .:/var/www/html:ro
|
- app_code:/var/www/html:ro
|
||||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
networks:
|
networks:
|
||||||
- termanager2
|
- termanager2
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -81,6 +83,8 @@ services:
|
|||||||
- termanager2
|
- termanager2
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
app_code:
|
||||||
|
driver: local
|
||||||
db_data:
|
db_data:
|
||||||
driver: local
|
driver: local
|
||||||
redis_data:
|
redis_data:
|
||||||
|
|||||||
2
docker/nginx/Dockerfile
Normal file
2
docker/nginx/Dockerfile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FROM nginx:1.25-alpine
|
||||||
|
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
@@ -42,14 +42,17 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Copy application code to staging area
|
||||||
|
COPY . /app-src/
|
||||||
|
|
||||||
# Copy PHP configuration
|
# 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 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
|
||||||
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
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|||||||
@@ -6,7 +6,17 @@ echo " TerManager2 - Entrypoint"
|
|||||||
echo "========================================="
|
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/framework/{cache,sessions,views}
|
||||||
mkdir -p storage/logs
|
mkdir -p storage/logs
|
||||||
|
|||||||
Reference in New Issue
Block a user