Compare commits

..

7 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
sulthan 650ed410ec update dockerfiles 2026-06-06 13:03:28 +07:00
sulthan c3cfba95f6 update docker ignore 2026-06-06 12:48:20 +07:00
5 changed files with 24 additions and 19 deletions
-1
View File
@@ -10,7 +10,6 @@ vendor
.dockerignore
docker-compose.yml
Dockerfile
Dockerfile.nginx
AGENTS.MD
DEPLOY.htaccess
DEPLOYindex.php
+9 -5
View File
@@ -10,9 +10,13 @@ FROM php:8.2-cli-alpine AS composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts
RUN composer install --no-dev --optimize-autoloader --no-scripts \
--ignore-platform-req=ext-gd \
--ignore-platform-req=ext-zip
COPY . .
RUN composer install --no-dev --optimize-autoloader
RUN composer install --no-dev --optimize-autoloader \
--ignore-platform-req=ext-gd \
--ignore-platform-req=ext-zip
FROM php:8.2-fpm-alpine AS ext-builder
@@ -52,10 +56,10 @@ WORKDIR /var/www/html
COPY docker-entrypoint.sh /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=node-build --chown=app:app /app/public/build ./public/build
COPY --from=composer --chown=app:app /app/vendor /app-source/vendor
COPY --from=node-build --chown=app:app /app/public/build /app-source/public/build
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["php-fpm"]
+4 -3
View File
@@ -10,7 +10,7 @@ services:
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
test: ["CMD-SHELL", "mysqladmin ping -h localhost --ssl=0 -u root -p\"$$MYSQL_ROOT_PASSWORD\""]
interval: 10s
timeout: 5s
retries: 10
@@ -22,6 +22,7 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- app-source:/var/www/html
- app-storage:/var/www/html/storage
- app-photos:/var/www/html/public/photos
environment:
@@ -49,14 +50,14 @@ services:
context: .
dockerfile: Dockerfile.nginx
volumes:
- app-source:/var/www/html:ro
- app-photos:/var/www/html/public/photos:ro
ports:
- "${NGINX_PORT:-80}:80"
depends_on:
- app
restart: unless-stopped
volumes:
app-source:
mariadb_data:
app-storage:
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
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
echo "Waiting for MySQL..."
for i in $(seq 1 30); do
@@ -78,9 +84,5 @@ php artisan view:cache
# 6. Storage link
php artisan storage:link 2>/dev/null || true
# 7. Switch to app user and start PHP-FPM
if [ "$(id -u)" = "0" ]; then
exec su-exec app php-fpm
else
exec php-fpm
fi
# 7. Start PHP-FPM
exec php-fpm
+3 -4
View File
@@ -1,16 +1,15 @@
server {
listen 80;
server_name _;
root /var/www/html/public;
index index.php;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php?$query_string;
try_files $uri /index.php?$query_string;
}
location ~ \.php$ {
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;
}