-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
42 lines (31 loc) · 1.12 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
# Dockerfile for building the full-stack app
# App Description
# Frontend: React App project at ./
# Server: Express Server code at ./server/
#
# The frontend is built and the generated build is server by the server.
#
# Environment Configs:
## Environment variables for the website (Frontend)
### REACT_APP_SERVER_URL=<PASTE SERVER URL HERE>
## Environment variables for the server (backend)
### MONGO_CONNECTION_URL=<PASTE MONGO DB CONNECTION STRING HERE>
### PORT=<INSERT PORT NUMBER HERE>
# Build react client (Node v16)
FROM node:16-alpine
# Set working directory to /app/
WORKDIR /app
# Copy ./package.json (frontend) to /app/
COPY package*.json ./
# Installing frontend dependencies
RUN npm install --silent --force
# copy project files to /app/
COPY . .
# Produce a production build of the frontend (./) , stored in /build/
RUN npm run build
# Install server dependencies from ./server/package.json
RUN npm install --silent --prefix server/
# Expose PORT 5000, the server runs on this by default
EXPOSE 5000
# Execute custom script to start the Server, this script is defined in ./package.json
CMD ["npm","run","production"]