Consolidate containers
This commit is contained in:
parent
9ef05f9f57
commit
e82dfb03fc
5 changed files with 50 additions and 33 deletions
|
|
@ -32,7 +32,9 @@ RUN apk add --no-cache \
|
||||||
zip \
|
zip \
|
||||||
unzip \
|
unzip \
|
||||||
oniguruma-dev \
|
oniguruma-dev \
|
||||||
mysql-client
|
mysql-client \
|
||||||
|
nginx \
|
||||||
|
supervisor
|
||||||
|
|
||||||
# Install PHP extensions
|
# Install PHP extensions
|
||||||
RUN docker-php-ext-install \
|
RUN docker-php-ext-install \
|
||||||
|
|
@ -58,22 +60,18 @@ RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||||
# Copy built frontend assets from builder stage
|
# Copy built frontend assets from builder stage
|
||||||
COPY --from=frontend-builder /app/public/build/ ./public/build/
|
COPY --from=frontend-builder /app/public/build/ ./public/build/
|
||||||
|
|
||||||
|
# Copy nginx and supervisor configurations
|
||||||
|
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
|
||||||
|
COPY docker/supervisord.conf /etc/supervisord.conf
|
||||||
|
COPY docker/start-app.sh /usr/local/bin/start-app
|
||||||
|
|
||||||
# Set proper permissions
|
# Set proper permissions
|
||||||
RUN chown -R www-data:www-data storage bootstrap/cache public/build \
|
RUN chown -R www-data:www-data storage bootstrap/cache public/build \
|
||||||
&& chmod -R 755 storage bootstrap/cache
|
&& chmod -R 755 storage bootstrap/cache \
|
||||||
|
|
||||||
# Create a startup script
|
|
||||||
RUN echo '#!/bin/sh' > /usr/local/bin/start-app \
|
|
||||||
&& echo 'cp -r /var/www/html/public/. /var/www/html/public_shared/ 2>/dev/null || true' >> /usr/local/bin/start-app \
|
|
||||||
&& echo 'php artisan config:cache' >> /usr/local/bin/start-app \
|
|
||||||
&& echo 'php artisan route:cache' >> /usr/local/bin/start-app \
|
|
||||||
&& echo 'php artisan view:cache' >> /usr/local/bin/start-app \
|
|
||||||
&& echo 'php artisan migrate --force' >> /usr/local/bin/start-app \
|
|
||||||
&& echo 'php-fpm' >> /usr/local/bin/start-app \
|
|
||||||
&& chmod +x /usr/local/bin/start-app
|
&& chmod +x /usr/local/bin/start-app
|
||||||
|
|
||||||
# Expose port 9000 for PHP-FPM
|
# Expose port 80 for nginx
|
||||||
EXPOSE 9000
|
EXPOSE 80
|
||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,7 @@ version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: codeberg.org/lvl0/incr:0.1.0
|
image: codeberg.org/lvl0/incr:0.1.14
|
||||||
# build:
|
|
||||||
# context: ../
|
|
||||||
# dockerfile: docker/Dockerfile
|
|
||||||
container_name: incr-app
|
container_name: incr-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
working_dir: /var/www/html
|
working_dir: /var/www/html
|
||||||
|
|
@ -21,6 +18,8 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ../storage:/var/www/html/storage
|
- ../storage:/var/www/html/storage
|
||||||
- ../public:/var/www/html/public
|
- ../public:/var/www/html/public
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
networks:
|
networks:
|
||||||
|
|
@ -42,20 +41,6 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- incr-network
|
- incr-network
|
||||||
|
|
||||||
nginx:
|
|
||||||
image: nginx:alpine
|
|
||||||
container_name: incr-nginx
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
volumes:
|
|
||||||
- ../public:/var/www/html/public:ro
|
|
||||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
depends_on:
|
|
||||||
- app
|
|
||||||
networks:
|
|
||||||
- incr-network
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
incr-network:
|
incr-network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ server {
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
fastcgi_pass app:9000;
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
|
|
|
||||||
13
docker/start-app.sh
Normal file
13
docker/start-app.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Copy public files to shared volume if needed
|
||||||
|
cp -r /var/www/html/public/. /var/www/html/public_shared/ 2>/dev/null || true
|
||||||
|
|
||||||
|
# Laravel optimizations
|
||||||
|
php artisan config:cache
|
||||||
|
php artisan route:cache
|
||||||
|
php artisan view:cache
|
||||||
|
php artisan migrate --force
|
||||||
|
|
||||||
|
# Start supervisor to manage nginx and php-fpm
|
||||||
|
supervisord -c /etc/supervisord.conf
|
||||||
21
docker/supervisord.conf
Normal file
21
docker/supervisord.conf
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
user=root
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
command=nginx -g "daemon off;"
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
|
[program:php-fpm]
|
||||||
|
command=php-fpm --nodaemonize
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
Loading…
Reference in a new issue