From 3f685180161eed3bfc8f96ab6107e6ea9d783dad Mon Sep 17 00:00:00 2001 From: Vincent <407859+vincentchalamon@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:30:45 +0200 Subject: [PATCH] fix: PWA config and other minor improvements (#2551) * fix: typos * fix: fix from review + from vercel/next.js diff --- .github/workflows/ci.yml | 2 +- api/frankenphp/docker-entrypoint.sh | 2 +- compose.prod.yaml | 2 +- helm/api-platform/templates/configmap.yaml | 2 ++ helm/api-platform/templates/deployment.yaml | 10 ++++++++++ helm/api-platform/values.yaml | 1 + pwa/Dockerfile | 6 +++++- 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53aa1357feb..71ddf81bc50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,4 +70,4 @@ jobs: name: Lint Dockerfiles uses: hadolint/hadolint-action@v3.1.0 with: - recursive: true + recursive: true diff --git a/api/frankenphp/docker-entrypoint.sh b/api/frankenphp/docker-entrypoint.sh index 3d4dfd9d91c..547c14fcaf0 100755 --- a/api/frankenphp/docker-entrypoint.sh +++ b/api/frankenphp/docker-entrypoint.sh @@ -2,7 +2,7 @@ set -e if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then - if [ ! -d 'vendor/' ]; then + if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then composer install --prefer-dist --no-progress --no-interaction fi diff --git a/compose.prod.yaml b/compose.prod.yaml index 6a03f237127..731c5f0a57b 100644 --- a/compose.prod.yaml +++ b/compose.prod.yaml @@ -12,7 +12,7 @@ services: MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET} pwa: - build: + build: context: ./pwa target: prod diff --git a/helm/api-platform/templates/configmap.yaml b/helm/api-platform/templates/configmap.yaml index 19c2a61d7f5..58199dcc537 100644 --- a/helm/api-platform/templates/configmap.yaml +++ b/helm/api-platform/templates/configmap.yaml @@ -12,3 +12,5 @@ data: php-trusted-proxies: "{{ join "," .Values.php.trustedProxies }}" mercure-url: "http://{{ include "api-platform.fullname" . }}/.well-known/mercure" mercure-public-url: {{ .Values.mercure.publicUrl | default "http://127.0.0.1/.well-known/mercure" | quote }} + mercure-extra-directives: {{ .Values.mercure.extraDirectives | quote }} + caddy-global-options: {{ .Values.php.caddyGlobalOptions | quote }} diff --git a/helm/api-platform/templates/deployment.yaml b/helm/api-platform/templates/deployment.yaml index 003b9931a42..ce602360a69 100644 --- a/helm/api-platform/templates/deployment.yaml +++ b/helm/api-platform/templates/deployment.yaml @@ -85,6 +85,11 @@ spec: secretKeyRef: name: {{ include "api-platform.fullname" . }} key: database-url + - name: CADDY_GLOBAL_OPTIONS + valueFrom: + configMapKeyRef: + name: {{ include "api-platform.fullname" . }} + key: caddy-global-options - name: MERCURE_URL valueFrom: configMapKeyRef: @@ -95,6 +100,11 @@ spec: configMapKeyRef: name: {{ include "api-platform.fullname" . }} key: mercure-public-url + - name: MERCURE_EXTRA_DIRECTIVES + valueFrom: + configMapKeyRef: + name: {{ include "api-platform.fullname" . }} + key: mercure-extra-directives - name: MERCURE_JWT_SECRET valueFrom: secretKeyRef: diff --git a/helm/api-platform/values.yaml b/helm/api-platform/values.yaml index 729c8ee5f4b..b0a4f6bbd82 100644 --- a/helm/api-platform/values.yaml +++ b/helm/api-platform/values.yaml @@ -18,6 +18,7 @@ php: - "10.0.0.0/8" - "172.16.0.0/12" - "192.168.0.0/16" + caddyGlobalOptions: "" pwa: image: diff --git a/pwa/Dockerfile b/pwa/Dockerfile index 87052c2f17a..a7ebabff467 100644 --- a/pwa/Dockerfile +++ b/pwa/Dockerfile @@ -59,6 +59,10 @@ RUN addgroup --system --gid 1001 nodejs; \ COPY --from=builder --link /srv/app/public ./public +# Set the correct permission for prerender cache +RUN mkdir .next; \ + chown nextjs:nodejs .next + # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --link --chown=1001:1001 /srv/app/.next/standalone ./ @@ -69,6 +73,6 @@ USER nextjs EXPOSE 3000 ENV PORT 3000 -ENV HOSTNAME localhost +ENV HOSTNAME "0.0.0.0" CMD ["node", "server.js"]