Skip to content

Commit

Permalink
perf(docker): prefer distroless containers for runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiDood committed Aug 12, 2024
1 parent f92c56a commit 4691e49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# syntax=docker/dockerfile:1.7-labs
FROM node:22.5.1-alpine3.20 AS build
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable pnpm
WORKDIR /drap
COPY pnpm-lock.yaml ./
COPY pnpm-lock.yaml .
RUN pnpm fetch
COPY . ./
COPY . .
RUN pnpm install --recursive --offline
RUN pnpm --filter=drap-email --prod deploy /prod/email && pnpm --filter=drap-app --prod deploy /prod/app
RUN pnpm --parallel --recursive build && mv email/dist/ /prod/email && mv app/build/ /prod/app

FROM node:22.5.1-alpine3.20 AS deploy
COPY --from=build /prod/ /drap/
FROM gcr.io/distroless/nodejs22-debian12:nonroot-amd64 AS deploy
COPY --from=build /prod/ ~/drap/
EXPOSE 3000
USER node

# This is the command to start the SvelteKit server. The background email worker
# should be spawned as a separate process somehow. When deploying to Fly.io
# (see the fly.toml), we use Process Groups to spawn both the main SvelteKit
# server and the email worker at the same time. For the sake of supplying a
# # default entry point, the following `CMD` starts the SvelteKit server.
CMD ["node", "/prod/app/build/index.js"]
CMD ["~/drap/app/build/index.js"]
4 changes: 2 additions & 2 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ app = 'drap-app'
primary_region = 'sin'

[processes]
app = 'node /drap/app/build/index.js'
email = 'node --enable-source-maps /drap/email/dist/main.js'
app = '~/drap/app/build/index.js'
email = '--enable-source-maps ~/drap/email/dist/main.js'

[http_service]
processes = ['app']
Expand Down

0 comments on commit 4691e49

Please sign in to comment.