Add entrypoint script and update Dockerfile for proper initialization; modify Traefik labels for production environment
All checks were successful
Deploy Production (admin.merchbay.app) / deploy (push) Successful in 2m42s

This commit is contained in:
Frank John Begornia
2025-12-21 05:06:11 +08:00
parent 4ce000e95b
commit 678a8842f4
3 changed files with 33 additions and 8 deletions

View File

@@ -32,6 +32,10 @@ WORKDIR /var/www/html
# Copy existing application directory contents
COPY . /var/www/html
# Copy and set permissions for entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Create storage directories and set permissions
RUN mkdir -p storage/framework/views \
storage/framework/cache \
@@ -67,5 +71,8 @@ RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Expose port 80
EXPOSE 80
# Set entrypoint
ENTRYPOINT ["docker-entrypoint.sh"]
# Start Apache
CMD ["apache2-foreground"]

View File

@@ -21,15 +21,15 @@ services:
labels:
- "traefik.enable=true"
# Production environment (merchbay.app)
- "traefik.http.routers.merchbay-admin-dev.rule=Host(`merchbay.app`)"
- "traefik.http.routers.merchbay-admin-dev.entrypoints=websecure"
- "traefik.http.routers.merchbay-admin-dev.tls=true"
- "traefik.http.routers.merchbay-admin-dev.tls.certresolver=le"
- "traefik.http.services.merchbay-admin-dev.loadbalancer.server.port=80"
- "traefik.http.routers.merchbay-admin-prod.rule=Host(`merchbay.app`)"
- "traefik.http.routers.merchbay-admin-prod.entrypoints=websecure"
- "traefik.http.routers.merchbay-admin-prod.tls=true"
- "traefik.http.routers.merchbay-admin-prod.tls.certresolver=le"
- "traefik.http.services.merchbay-admin-prod.loadbalancer.server.port=80"
# HTTP to HTTPS redirect
- "traefik.http.routers.merchbay-admin-dev-http.rule=Host(`merchbay.app`)"
- "traefik.http.routers.merchbay-admin-dev-http.entrypoints=web"
- "traefik.http.routers.merchbay-admin-dev-http.middlewares=https-redirect"
- "traefik.http.routers.merchbay-admin-prod-http.rule=Host(`merchbay.app`)"
- "traefik.http.routers.merchbay-admin-prod-http.entrypoints=web"
- "traefik.http.routers.merchbay-admin-prod-http.middlewares=https-redirect"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
networks:
- traefik-public

18
docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
set -e
# Create storage directory structure if it doesn't exist
mkdir -p storage/framework/views
mkdir -p storage/framework/cache
mkdir -p storage/framework/sessions
mkdir -p storage/logs
mkdir -p storage/app/public
mkdir -p bootstrap/cache
mkdir -p public/uploads
# Set proper permissions
chown -R www-data:www-data storage bootstrap/cache public/uploads
chmod -R 775 storage bootstrap/cache public/uploads
# Execute the main command
exec "$@"