Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (61 loc) · 2.5 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (61 loc) · 2.5 KB
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
71
72
73
74
75
76
77
78
79
FROM node:22.23.4-alpine3.23@sha256:206878a60dc7014193f418ab9259b6110c15fbd514b3044a267be706509944e4 AS base
ARG SOURCE_DATE_EPOCH
ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . ./app
WORKDIR /app
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store CI=true pnpm install --prod --frozen-lockfile
# Remove large native modules for linux-x64-gnu platform (we use alpine which is musl-based)
# not supported in pnpm for now due to this bug: https://github.com/pnpm/pnpm/issues/9654
RUN du -shL ./node_modules/.pnpm/* | grep '[0-9]M.*' | grep 'linux-x64-gnu@' | awk '{print $2}' | xargs rm -rf
FROM base AS build
ARG COMMIT_TAG
ENV COMMIT_TAG=${COMMIT_TAG}
RUN \
case "${TARGETPLATFORM}" in \
'linux/arm64' | 'linux/arm/v7') \
apk update && \
apk add --no-cache python3 make g++ gcc libc6-compat bash && \
npm install --global node-gyp \
;; \
esac
RUN --mount=type=cache,id=pnpm,target=/pnpm/store CYPRESS_INSTALL_BINARY=0 pnpm install --frozen-lockfile
RUN pnpm build
FROM node:22.23.4-alpine3.23@sha256:206878a60dc7014193f418ab9259b6110c15fbd514b3044a267be706509944e4
ARG SOURCE_DATE_EPOCH
ARG COMMIT_TAG
ENV NODE_ENV=production
ENV COMMIT_TAG=${COMMIT_TAG}
RUN apk add --no-cache tzdata
USER node:node
WORKDIR /app
COPY --chown=node:node --exclude=src --exclude=server . .
# @next/swc is only for next build and for next.config.ts
# ts-node, @swc/core, and typescript are only needed for build-time type checking and compilation
# ace-builds, country-flag-icons and @heroicons subfolders are large module files not needed for production
# Source map files are not needed for production
# Remove large module files not needed for production
COPY --chown=node:node --from=prod-deps \
--exclude=.pnpm/@next+swc-* \
--exclude=.pnpm/@swc+core* \
--exclude=.pnpm/ts-node@* \
--exclude=.pnpm/typescript@* \
--exclude=**/ace-builds/src-noconflict \
--exclude=**/ace-builds/src \
--exclude=**/ace-builds/src-min \
--exclude=**/country-flag-icons/react \
--exclude=**/country-flag-icons/string \
--exclude=**/country-flag-icons/1x1 \
--exclude=**/@heroicons/react/16 \
--exclude=**/*.map \
/app/node_modules ./node_modules
COPY --chown=node:node --from=build --exclude=cache --exclude=**/*.map /app/.next ./.next
COPY --chown=node:node --from=build /app/dist ./dist
RUN touch config/DOCKER && \
echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json
EXPOSE 5055
CMD [ "npm", "start" ]