Compare commits

...

5 Commits

Author SHA1 Message Date
sulthan 553f90d482 changed approach to shared volumes between nginx and app 2026-06-06 15:26:07 +07:00
sulthan fddf5398fc update nginx conf 2026-06-06 15:07:55 +07:00
sulthan 9c4e732af3 update docker 2026-06-06 13:46:53 +07:00
sulthan 6968a3d528 fix infinite loop caused by mariadb and fpm 2026-06-06 13:27:18 +07:00
sulthan 85a6e3bd0d Update docker-compose.yml 2026-06-06 13:18:30 +07:00
4 changed files with 18 additions and 16 deletions
+3 -3
View File
@@ -56,10 +56,10 @@ WORKDIR /var/www/html
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY --chown=app:app . . COPY --chown=app:app . /app-source
COPY --from=composer --chown=app:app /app/vendor ./vendor COPY --from=composer --chown=app:app /app/vendor /app-source/vendor
COPY --from=node-build --chown=app:app /app/public/build ./public/build COPY --from=node-build --chown=app:app /app/public/build /app-source/public/build
ENTRYPOINT ["docker-entrypoint.sh"] ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["php-fpm"] CMD ["php-fpm"]
+4 -3
View File
@@ -10,7 +10,7 @@ services:
MYSQL_USER: ${DB_USERNAME} MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD} MYSQL_PASSWORD: ${DB_PASSWORD}
healthcheck: healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] test: ["CMD-SHELL", "mysqladmin ping -h localhost --ssl=0 -u root -p\"$$MYSQL_ROOT_PASSWORD\""]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 10 retries: 10
@@ -22,6 +22,7 @@ services:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
volumes: volumes:
- app-source:/var/www/html
- app-storage:/var/www/html/storage - app-storage:/var/www/html/storage
- app-photos:/var/www/html/public/photos - app-photos:/var/www/html/public/photos
environment: environment:
@@ -49,14 +50,14 @@ services:
context: . context: .
dockerfile: Dockerfile.nginx dockerfile: Dockerfile.nginx
volumes: volumes:
- app-source:/var/www/html:ro
- app-photos:/var/www/html/public/photos:ro - app-photos:/var/www/html/public/photos:ro
ports:
- "${NGINX_PORT:-80}:80"
depends_on: depends_on:
- app - app
restart: unless-stopped restart: unless-stopped
volumes: volumes:
app-source:
mariadb_data: mariadb_data:
app-storage: app-storage:
app-photos: app-photos:
+8 -6
View File
@@ -14,6 +14,12 @@ if [ "$(id -u)" = "0" ]; then
chown -R app:app /var/www/html/storage /var/www/html/public/photos chown -R app:app /var/www/html/storage /var/www/html/public/photos
fi fi
# Sync app source from image to volume
if [ -d /app-source ]; then
echo "Syncing app source to volume..."
cp -a /app-source/. /var/www/html/
fi
# 1. Wait for MySQL # 1. Wait for MySQL
echo "Waiting for MySQL..." echo "Waiting for MySQL..."
for i in $(seq 1 30); do for i in $(seq 1 30); do
@@ -78,9 +84,5 @@ php artisan view:cache
# 6. Storage link # 6. Storage link
php artisan storage:link 2>/dev/null || true php artisan storage:link 2>/dev/null || true
# 7. Switch to app user and start PHP-FPM # 7. Start PHP-FPM
if [ "$(id -u)" = "0" ]; then exec php-fpm
exec su-exec app php-fpm
else
exec php-fpm
fi
+3 -4
View File
@@ -1,16 +1,15 @@
server { server {
listen 80; listen 80;
server_name _; server_name _;
root /var/www/html/public; root /var/www/html;
index index.php;
location / { location / {
try_files $uri $uri/ /index.php?$query_string; try_files $uri /index.php?$query_string;
} }
location ~ \.php$ { location ~ \.php$ {
fastcgi_pass app:9000; fastcgi_pass app:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;
} }