-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
55 lines (36 loc) · 1 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
FROM node:latest
# Prepare a temp directory for backend
RUN mkdir -p /temp/backend
# Copy backend to the temp directory
COPY /backend /temp/backend
WORKDIR /temp/backend
# Install dependencies
RUN npm install
# Build backend code
RUN npm run build:server
# Prepare a directory for finished application
RUN mkdir /app
# Move node_modules to the app directory
RUN mv /temp/backend/node_modules /app
# Move built backend go to the app
RUN mv /temp/backend/build/* /app
# Prepare a temp directory for frontend
RUN mkdir -p /temp/frontend
# Copy frontend to the temp directory
COPY /frontend /temp/frontend
WORKDIR /temp/frontend
# Install dependencies
RUN npm install
# Build frontend code
RUN npm run build
# Prepare a directory for built frontend code
RUN mkdir -p /app/client
# Move built front end to the app directory
RUN mv /temp/frontend/build/* /app/client
# Delete all temporary stuff
RUN rm -r /temp
WORKDIR /app
# Expose container port 5000
EXPOSE 5000
# Run application
ENTRYPOINT ["node", "index.js"]