Skip to content

Commit

Permalink
fix: ensure this works properly in docker (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Aug 10, 2024
1 parent 90aeed3 commit bd79d7d
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##

Expand All @@ -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

0 comments on commit bd79d7d

Please sign in to comment.