-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (48 loc) · 1.89 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (48 loc) · 1.89 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
# syntax=docker/dockerfile:1
FROM node:22-bookworm-slim AS client-build
WORKDIR /app
RUN corepack enable
COPY package.json yarn.lock ./
COPY client/package.json ./client/package.json
COPY server/package.json ./server/package.json
RUN yarn install --frozen-lockfile
ARG REACT_APP_API_ORIGIN=
ARG REACT_APP_SOCKETIO_ORIGIN=
ARG REACT_APP_WCA_ORIGIN=https://www.worldcubeassociation.org
ARG REACT_APP_WCA_CLIENT_ID=
ENV REACT_APP_API_ORIGIN=${REACT_APP_API_ORIGIN}
ENV REACT_APP_SOCKETIO_ORIGIN=${REACT_APP_SOCKETIO_ORIGIN}
ENV REACT_APP_WCA_ORIGIN=${REACT_APP_WCA_ORIGIN}
ENV REACT_APP_WCA_CLIENT_ID=${REACT_APP_WCA_CLIENT_ID}
COPY client ./client
RUN yarn workspace letscube-client build
FROM node:22-bookworm-slim AS server-deps
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN corepack enable
COPY package.json yarn.lock ./
COPY client/package.json ./client/package.json
COPY server/package.json ./server/package.json
RUN yarn install --frozen-lockfile --production=true \
&& yarn cache clean \
&& mkdir -p server/node_modules
FROM node:22-bookworm-slim AS runtime
ENV NODE_ENV=prod
ENV PORT=8080
ENV SOCKETIO_PORT=9000
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --system letscube \
&& useradd --system --gid letscube --home-dir /app --shell /usr/sbin/nologin letscube
COPY --chown=letscube:letscube server ./server
COPY --from=server-deps --chown=letscube:letscube /app/node_modules ./node_modules
COPY --from=server-deps --chown=letscube:letscube /app/server/node_modules ./server/node_modules
COPY --from=client-build --chown=letscube:letscube /app/client/build ./client/build
COPY --from=client-build --chown=letscube:letscube /app/client/src/lib ./client/src/lib
USER letscube
EXPOSE 8080 9000
CMD ["node", "server/index.js"]