-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (41 loc) · 1.05 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
ARG PORT
# work on top of node image
FROM node:18
# specifiy working directory
WORKDIR /frontend
# make port argument available as environment variable
ENV PORT=$PORT
# init directories
RUN mkdir server && mkdir app
# install pm2
RUN npm install -g pm2
# ========================
# Server Setup
# ========================
# copy dependency files to docker image
COPY server/package.json server/
COPY server/yarn.lock server/
# install dependencies
RUN cd server && yarn install
# copy remaining assests to docker image
COPY server/ server/
# ========================
# Frontend Setup
# ========================
# copy dependency files to docker image
COPY app/package.json app/
COPY app/yarn.lock app/
# install dependencies
RUN cd app && yarn install
# copy remaining assests to docker image
COPY app/ app/
# build frontend code
RUN cd app && yarn build
# move static files to server
RUN mv app/dist server/
# Expose container port
EXPOSE $PORT
# set working directory to server
WORKDIR /frontend/server
# start server daemon
CMD [ "pm2-runtime", "start", "server.js" ]