-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathDockerfile
70 lines (58 loc) · 2.07 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
FROM node:22-slim as base
# set for base and all layer that inherit from it
ENV NODE_ENV="production" \
PNPM_HOME="/pnpm" \
PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN apt update -y && apt install -y libc-dev fftw-dev gcc g++ make libc6 ca-certificates
FROM base as base-env
WORKDIR /app
# these are used for sourcemap publishing, and to prevent cache busting
# on docker layers - they SHOULD NOT CHANGE between targets
ARG SENTRY_DSN
ARG API_SERVER
ARG URL_PREFIX
ARG GOOGLE_CLIENT_ID
ARG FATHOM_SITE_ID
ENV SENTRY_DSN=$SENTRY_DSN \
API_SERVER=$API_SERVER \
URL_PREFIX=$URL_PREFIX \
GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID \
FATHOM_SITE_ID=$FATHOM_SITE_ID
ADD .npmrc package.json pnpm-lock.yaml pnpm-workspace.yaml .
ADD apps/cli/package.json ./apps/cli/package.json
ADD apps/web/package.json ./apps/web/package.json
ADD apps/server/package.json ./apps/server/package.json
# given packages are mostly universally shared code, this simplifies our logic
ADD packages .
# ensure latest corepack otherwise we could hit cert issues
RUN npm i -g corepack@latest
RUN --mount=type=cache,id=pnpm,target=/pnpm/store NODE_ENV=development pnpm install --frozen-lockfile
ADD . .
# We run this again as Docker seems to wipe our node_modules, but they're cached
RUN --mount=type=cache,id=pnpm,target=/pnpm/store NODE_ENV=development pnpm install --frozen-lockfile
# needs bound before build
ARG VERSION
ARG SENTRY_PROJECT
ARG SENTRY_ORG
ARG SENTRY_AUTH_TOKEN
ENV VERSION=$VERSION \
SENTRY_RELEASE=$VERSION \
SENTRY_ORG=$SENTRY_ORG \
SENTRY_PROJECT=$SENTRY_PROJECT \
SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
RUN pnpm build:docker
# TODO: it'd be nice to optimize the build, but we're beholden with a ton of node_modules from having to use hoisting
# Prune node_modules to prod deps
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store NODE_ENV=development pnpm install --prod --frozen-lockfile
# Wipe the store
# RUN rm -rf /pnpm/store
ENV HOST=0.0.0.0 \
PORT=4000
EXPOSE 4000
WORKDIR /app
ARG VERSION
ENV VERSION $VERSION
# override the command
# e.g. pnpm start:worker
CMD ["exit", "1"]