Skip to content

Commit

Permalink
fix: production docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
keenthekeen committed May 8, 2024
1 parent 0da4507 commit de221c7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/storage/framework/testing/*
/storage/framework/views/*
/storage/logs/*
.env
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY --from=base ${APP_BASE_DIR} /app
WORKDIR /app
RUN ls .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm build

FROM base
COPY --from=node /app/public/build ${APP_BASE_DIR}/public/build
RUN chown -R www-data /var/www/html/storage

USER www-data
CMD ["unitd", "--no-daemon"]
5 changes: 5 additions & 0 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ class TrustProxies extends Middleware
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;

// Load the trusted proxies from the config file
public function __construct() {
$this->proxies = config('app.trusted_proxies', []);
}
}
4 changes: 4 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,8 @@

],

'trusted_proxies' => value(function ($config) {
return empty($config) ? [] : explode(',', $config);
}, env('TRUSTED_PROXIES', '')),

];
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Production environment
services:
laravel:
build:
context: ./
dockerfile: Dockerfile
# image: serversideup/php:8.3-unit
volumes:
- ./database:/var/www/html/database:Z
- ./storage:/var/www/html/storage:Z
# restart: on-failure:2
- /storage/smcu-admin-storage:/var/www/html/storage/app:Z
# - ./database:/var/www/html/database:Z # For testing
# - ./.env:/var/www/html/.env:Z # For testing
restart: on-failure:2
environment:
# https://serversideup.net/open-source/docker-php/docs/getting-started/default-configurations
- PHP_UPLOAD_MAX_FILE_SIZE="30M"
- PHP_OPCACHE_ENABLE=1
# Enable Laravel config/route/view/event caching (caution: do not call env() in other places than config files)
- AUTORUN_ENABLED=true
#- AUTORUN_ENABLED=true
- APP_ENV=production
- APP_DEBUG=false
- REDIS_HOST=redis
Expand All @@ -22,10 +23,8 @@ services:
- CACHE_DRIVER=redis
- LOG_CHANNEL=stderr
- SESSION_DRIVER=redis
# For testing
ports:
- "8080:8080"
- "8443:8443"
#ports: # For testing
# - "8080:8080"
labels:
# Traefik configuration discovery
# https://doc.traefik.io/traefik/providers/docker/#routing-configuration-with-labels
Expand All @@ -37,6 +36,7 @@ services:
- "traefik.http.routers.admin-http.entrypoints=web"
- "traefik.http.routers.admin-https.rule=Host(`admin.docchula.com`)"
- "traefik.http.routers.admin-https.entrypoints=websecure"
- "traefik.http.routers.admin-https.tls.certresolver=leresolver"
- "traefik.http.services.admin-https.loadbalancer.server.port=8080"
deploy:
resources:
Expand All @@ -49,7 +49,7 @@ services:
image: redis:7-alpine
restart: unless-stopped
volumes:
- cache:/data
- redis-cache:/data
environment:
- REDIS_PASSWORD=null
- REDIS_PORT=6379
Expand All @@ -61,5 +61,5 @@ services:
memory: 500M

volumes:
cache:
redis-cache:
driver: local

0 comments on commit de221c7

Please sign in to comment.