Skip to content

Commit

Permalink
refactor(docker): separate install step from source copy
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiDood committed Aug 5, 2024
1 parent d096b52 commit a96ad91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# syntax=docker/dockerfile:1.7-labs

# https://pnpm.io/docker
FROM node:22.5.1-alpine3.20 AS base
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 . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

FROM base AS build
COPY pnpm-lock.yaml ./
RUN pnpm fetch
COPY . ./
RUN pnpm install --recursive --offline
RUN pnpm --parallel --recursive build
RUN pnpm --filter=drap-email --prod deploy /prod/email
RUN pnpm --filter=drap-app --prod deploy /prod/app

FROM node:22.5.1-alpine3.20 AS deploy
COPY --from=build /prod /prod
COPY --from=build /prod/ /drap/
EXPOSE 3000
CMD tail -f /dev/null

# 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"]
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 /prod/app/build/index.js'
email = 'node --enable-source-maps /prod/email/dist/main.js'
app = 'node /drap/app/build/index.js'
email = 'node --enable-source-maps /drap/email/dist/main.js'

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

0 comments on commit a96ad91

Please sign in to comment.