From 3b73a10b49fc5c88905825bcc9e066962fb6fdbe Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 27 Nov 2022 12:17:00 +0200 Subject: [PATCH] more docker sutff --- Dockerfile | 6 ++++++ entrypoint.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 136a24e..5ae9a18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,9 @@ WORKDIR /app COPY --chown=node:node --from=deps /app/node_modules ./node_modules COPY --chown=node:node . . +ENV NODE_ENV production +ENV NEXT_PUBLIC_URL APP_NEXT_PUBLIC_URL +ENV NEXT_PUBLIC_UPLOADS_URL APP_NEXT_PUBLIC_UPLOADS_URL RUN npm run build RUN npm ci --omit=dev && npm cache clean --force @@ -35,10 +38,13 @@ ENV NODE_ENV production COPY --chown=node:node --from=builder /app/node_modules ./node_modules COPY --chown=node:node --from=builder /app/package*.json ./ +COPY --chown=node:node --from=builder /app/entrypoint.sh ./ +COPY --chown=node:node --from=builder /app/next.config.js ./ COPY --chown=node:node --from=builder /app/public ./public COPY --chown=node:node --from=builder /app/.next ./.next EXPOSE 3000 +ENTRYPOINT ["/app/entrypoint.sh"] CMD ["node_modules/.bin/next", "start"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..4c97687 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -Ex + +function apply_path { + test -n "$NEXT_PUBLIC_URL" + test -n "$NEXT_PUBLIC_UPLOADS_URL" + + find /app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#APP_NEXT_PUBLIC_URL#$NEXT_PUBLIC_URL#g" + find /app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#APP_NEXT_PUBLIC_UPLOADS_URL#$NEXT_PUBLIC_UPLOADS_URL#g" +} + +apply_path +exec "$@"