From ac6739c74f13332578d7fbb687eb41062eb8e26c Mon Sep 17 00:00:00 2001 From: PseudoResonance Date: Wed, 8 Jan 2025 05:11:54 -0800 Subject: [PATCH] Speed up Docker build and fix entrypoint permissions --- .github/docker/entrypoint.sh | 6 +++--- Dockerfile | 11 +++++++---- compose.yml | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index 653c3e4bad..583db17910 100644 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -33,17 +33,17 @@ ln -s /pelican-data/database/database.sqlite /var/www/html/database/ if ! grep -q "APP_KEY=" .env || grep -q "APP_KEY=$" .env; then echo "Generating APP_KEY..." - php artisan key:generate --force + su -s /bin/ash -c "php artisan key:generate --force" www-data else echo "APP_KEY is already set." fi ## make sure the db is set up echo -e "Migrating Database" -php artisan migrate --force +su -s /bin/ash -c "php artisan migrate --force" www-data echo -e "Optimizing Filament" -php artisan filament:optimize +su -s /bin/ash -c "php artisan filament:optimize" www-data ## start cronjobs for the queue echo -e "Starting cron jobs." diff --git a/Dockerfile b/Dockerfile index 3e2da64825..379257e762 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,14 @@ FROM node:20-alpine AS yarn WORKDIR /build -COPY . ./ +COPY package.json yarn.lock ./ RUN yarn config set network-timeout 300000 \ - && yarn install --frozen-lockfile \ - && yarn run build:production + && yarn install --frozen-lockfile + +COPY . ./ + +RUN yarn run build:production FROM php:8.3-fpm-alpine # FROM --platform=$TARGETOS/$TARGETARCH php:8.3-fpm-alpine @@ -49,7 +52,7 @@ RUN cp .github/docker/supervisord.conf /etc/supervisord.conf && \ mkdir /var/log/supervisord/ HEALTHCHECK --interval=5m --timeout=10s --start-period=5s --retries=3 \ - CMD curl -f http://localhost/up || exit 1 + CMD curl -f http://localhost/up || exit 1 EXPOSE 80 443 diff --git a/compose.yml b/compose.yml index 6dab7145e3..5b55249a22 100644 --- a/compose.yml +++ b/compose.yml @@ -28,6 +28,8 @@ x-common: services: panel: image: ghcr.io/pelican-dev/panel:latest + build: + dockerfile: ./Dockerfile restart: always networks: - default