From bd79d7d1be9af7fccf430276001b383075f20cd2 Mon Sep 17 00:00:00 2001 From: Jeroen Claassens Date: Sat, 10 Aug 2024 17:14:34 +0200 Subject: [PATCH] fix: ensure this works properly in docker (hopefully) --- Dockerfile | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1bf8b0d..ca78b84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,32 +7,23 @@ WORKDIR /usr/src/app ENV YARN_DISABLE_GIT_HOOKS=1 ENV CI=true -RUN set -ex - -COPY --chown=node:node package.json . COPY --chown=node:node yarn.lock . +COPY --chown=node:node package.json . COPY --chown=node:node .yarnrc.yml . COPY --chown=node:node .yarn/ .yarn/ -COPY --chown=node:node ./concourse/check /opt/resource/check -COPY --chown=node:node ./concourse/in /opt/resource/in -COPY --chown=node:node ./concourse/out /opt/resource/out - -RUN chmod +x /opt/resource/check /opt/resource/in /opt/resource/out - -RUN yarn install --immutable - ## Builder stage ## FROM base AS builder -COPY --from=base --chown=node:node /usr/src/app/node_modules/ /usr/src/app/node_modules/ +ENV NODE_ENV="development" COPY --chown=node:node tsconfig.base.json . COPY --chown=node:node tsup.config.ts . COPY --chown=node:node src/ src/ -RUN yarn build +RUN yarn install --immutable \ + && yarn build ## Runtime stage ## @@ -41,18 +32,19 @@ FROM base AS runtime ENV NODE_ENV="production" ENV NODE_OPTIONS="--enable-source-maps" -# Create a directory for Concourse scripts -RUN mkdir -p /opt/resource - # Copy Concourse scripts -COPY --from=base /opt/resource/check /opt/resource/check -COPY --from=base /opt/resource/in /opt/resource/in -COPY --from=base /opt/resource/out /opt/resource/out +COPY --chown=node:node ./concourse/check /opt/resource/check +COPY --chown=node:node ./concourse/in /opt/resource/in +COPY --chown=node:node ./concourse/out /opt/resource/out -# Copy NodeJS scripts -COPY --from=base --chown=node:node /usr/src/app/node_modules/ /usr/src/app/node_modules/ +# Copy NodeJS ouptut COPY --from=builder --chown=node:node /usr/src/app/dist/ /usr/src/app/dist/ +RUN yarn workspaces focus --all --production \ + && chown -R node:node /opt/resource/ \ + && chown node:node /usr/src/app/ \ + && chmod +x /opt/resource/check /opt/resource/in /opt/resource/out + USER node CMD echo "This container is not used directly."; exit 1