diff --git a/Dockerfile b/Dockerfile index fc01642..2ede059 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 2db491c..c44cb0b 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..01e2b44 --- /dev/null +++ b/docker-entrypoint.sh @@ -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 "$@"