-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathDockerfile
77 lines (58 loc) · 2 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
71
72
73
74
75
76
77
FROM library/node:20-alpine AS base
RUN mkdir -p /data \
&& chown -R node:node /data
FROM base AS development
RUN apk update \
&& apk add --no-cache bash curl
RUN USER=node && \
GROUP=node && \
curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.5.1/fixuid-0.5.1-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \
chown root:root /usr/local/bin/fixuid && \
chmod 4755 /usr/local/bin/fixuid && \
mkdir -p /etc/fixuid && \
printf "user: $USER\ngroup: $GROUP\npaths:\n - /\n - /data/node_modules\n" > /etc/fixuid/config.yml
COPY ./build/build_entrypoint.sh /
RUN chmod a+x /build_entrypoint.sh
# Define working directory.
WORKDIR /data
# Define working user.
USER node
# Define default command.
ENTRYPOINT ["/build_entrypoint.sh"]
CMD ["npm", "run", "dev"]
FROM base AS production-builds
RUN mkdir -p /dist \
&& chown -R node:node /dist
WORKDIR /data
COPY --chown=node:node . .
USER node
FROM production-builds AS build
USER node
RUN npm ci --include=dev \
&& npm run build \
&& cp -RT ./dist /dist \
&& rm -rf ./node_modules ./dist \
&& npm cache clean --force
FROM production-builds AS builtin
USER node
WORKDIR /data/builtin
RUN rm -rf ./src ./dist ./public \
&& mkdir -p ./src/content/docs ./src/pages ./src/images ./src/scss \
&& cp ../src/content/config.ts ./src/content \
&& cp -R ../src/content/docs/docs ./src/content/docs \
&& cp -R ../src/pages/api ./src/pages/api \
&& cp -R ../src/images/* ./src/images \
&& cp -R ../src/scss/* ./src/scss \
&& rm -f ./src/content/docs/*.* \
&& cp ./index.md ./src/content/docs \
&& mkdir -p ./public \
&& cp -R ../public/img ./public/img \
&& sed -i -r 's|url: "(.*?)"|url: "/api/openapi.yml"|' ./src/pages/api/index.astro \
&& cd .. \
&& npm ci --include=dev \
&& npm run builtin-build \
&& rm -rf ./node_modules \
&& cd builtin \
&& cp -RT ./dist /dist \
&& rm -rf ./src ./dist ./public ./node_modules \
&& npm cache clean --force