-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (40 loc) · 1.28 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
FROM node:18-alpine as builder1
# Workdir
WORKDIR /app
# Copy & install dependencies
COPY package.json yarn.lock ./
COPY workspaces/backend/package.json ./workspaces/backend/package.json
COPY workspaces/frontend/package.json ./workspaces/frontend/package.json
RUN yarn --network-timeout 1000000
# Copy source code & build
COPY workspaces ./workspaces
COPY workspaces/frontend/.env.prod ./workspaces/frontend/.env
RUN yarn api build
RUN yarn app build && yarn app export
# ===========================
FROM node:18-alpine as builder2
# Workdir
WORKDIR /app
# Copy & install dependencies
COPY workspaces/backend/package.json yarn.lock ./
RUN yarn --prod --network-timeout 1000000
# ===========================
FROM node:18-alpine
LABEL maintainer="[email protected]"
LABEL description="Setup server and serve static resource."
# Workdir
WORKDIR /app
# Copy source built
COPY --from=builder2 app/node_modules ./node_modules
COPY --from=builder1 app/workspaces/backend/dist ./dist
COPY --from=builder1 app/workspaces/backend/config/default.yml ./config/default.yml
COPY --from=builder1 app/workspaces/frontend/out ./client
# Env default
ENV NODE_ENV=prod \
APP_CLIENT_DIR=/app/client
# Export port
EXPOSE 8080
# Volumn db for sqlite
VOLUME [ "/app/db_data" ]
# Start app
ENTRYPOINT ["node", "dist/main"]