-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
56 lines (45 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
54
55
56
# this aggregates the web and api into a single file
# to take advantage of docker cache
# build step
FROM node:20-alpine as build
RUN npm install -g @vercel/[email protected]
WORKDIR /app
COPY package.json yarn.lock ./
COPY api/package.json api/
COPY api/.env.sh api/
COPY web/package.json web/
COPY web/public/ web/public/
RUN yarn install --frozen-lockfile
COPY turbo.json ./
COPY api/ api/
COPY web/src/ web/src/
COPY web/config-overrides.js web/tsconfig.json web/
WORKDIR /app
RUN yarn build
WORKDIR /app/api
RUN rm -r src
RUN cp dist/src -r src/
RUN npx ncc build src/main.js
WORKDIR /app
COPY web/nginx.conf web/
# ----- api only ------
# to build only back run
# docker build . --target api --tag my-api-tag`
FROM node:20-alpine as api
RUN npm install -g [email protected]
RUN apk add --no-cache \
git \
openssh-client \
ca-certificates
COPY --from=build /app/api/dist/index.js .
# For reading the version number
COPY --from=build /app/package.json .
ENTRYPOINT sh -c "forever index.js"
## ----- web only ------
# to build only front run
# docker build . --target web --tag my-web-tag
FROM nginx:stable-alpine as web
COPY --from=build /app/web/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx
COPY --from=build /app/web/build ./html
ENTRYPOINT sh -c "nginx -g 'daemon off;'"