ffreemt
commited on
Commit
·
2f1eec1
1
Parent(s):
32255e9
Update Dockerfile two-stage
Browse files- .gitignore +1 -0
- Dockerfile +14 -5
.gitignore
CHANGED
@@ -2,3 +2,4 @@ node_modules
|
|
2 |
dist
|
3 |
logs
|
4 |
dist/
|
|
|
|
2 |
dist
|
3 |
logs
|
4 |
dist/
|
5 |
+
Dockerfile-copy
|
Dockerfile
CHANGED
@@ -1,13 +1,22 @@
|
|
1 |
-
FROM node:18-bullseye-slim
|
2 |
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
3 |
|
4 |
WORKDIR /app
|
5 |
COPY . .
|
6 |
RUN chown -R 1000:1000 /app
|
7 |
USER 1000
|
8 |
-
RUN npm install
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
EXPOSE 7860
|
11 |
-
|
12 |
-
ENV NODE_OPTIONS="--max-old-space-size=12882"
|
13 |
CMD [ "npm", "start" ]
|
|
|
1 |
+
FROM node:18-bullseye-slim AS BUILD_IMAGE
|
2 |
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
3 |
|
4 |
WORKDIR /app
|
5 |
COPY . .
|
6 |
RUN chown -R 1000:1000 /app
|
7 |
USER 1000
|
8 |
+
RUN npm install && npm run build
|
9 |
+
|
10 |
+
FROM node:lts-alpine
|
11 |
+
|
12 |
+
COPY --from=BUILD_IMAGE /app/configs /app/configs
|
13 |
+
COPY --from=BUILD_IMAGE /app/package.json /app/package.json
|
14 |
+
COPY --from=BUILD_IMAGE /app/dist /app/dist
|
15 |
+
COPY --from=BUILD_IMAGE /app/public /app/public
|
16 |
+
COPY --from=BUILD_IMAGE /app/node_modules /app/node_modules
|
17 |
+
|
18 |
+
WORKDIR /app
|
19 |
+
|
20 |
EXPOSE 7860
|
21 |
+
|
|
|
22 |
CMD [ "npm", "start" ]
|