-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (42 loc) · 1.8 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (42 loc) · 1.8 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
FROM node:16-slim AS build
WORKDIR /usr/src/app
# node:16-slim is Debian buster (EOL). Its apt repos moved to archive.debian.org.
RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list \
&& echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until \
&& apt-get update \
&& apt-get install -y git
RUN rm -rf /var/cache/apt/archives
# Client env values baked at build time by webpack.EnvironmentPlugin.
ARG GOOGLE_CLIENT_ID=
ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID
COPY ./package.json ./yarn.lock ./
COPY ./config ./config
COPY ./static ./static
COPY ./src ./src
COPY ./tsconfig.json ./webpack.config.js ./.babelrc ./
COPY ./favicon.ico ./
RUN yarn install --no-progress --pure-lockfile --prefer-offline
RUN yarn build
FROM node:16-slim
WORKDIR /usr/src/app
# node:16-slim is Debian buster (EOL). Its apt repos moved to archive.debian.org.
RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list \
&& echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until \
&& apt-get update \
&& apt-get install -y p7zip p7zip-full zip
RUN rm -rf /var/cache/apt/archives
# Runtime env (read at runtime by the server, except GOOGLE_CLIENT_ID
# which was baked into the client bundle in the build stage).
ENV NODE_ENV=production
COPY ./favicon.ico /usr/src/app/favicon.ico
COPY ./static/images /usr/src/app/static/images
COPY ./static/styles /usr/src/app/static/styles
COPY --from=build /usr/src/app/build /usr/src/app/build
COPY --from=build /usr/src/app/node_modules /usr/src/app/node_modules
EXPOSE 3000
# Course upload handling writes temp files into build/server and ./uploads.
RUN mkdir -p ./uploads \
&& chmod +x ./build/server \
&& chown -R node:node ./build/server ./uploads
USER node
CMD [ "node", "./build/server" ]