Skip to content

Commit bf445f4

Browse files
feat: update Dockerfile to build frontend with react-scripts and copy build output
1 parent 2341c18 commit bf445f4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
FROM node:16-alpine
1+
FROM node:16-alpine AS build-stage
22

33
WORKDIR /app
4+
45
RUN npm install -g @babel/cli
56
COPY backend/package*.json ./backend/
67
RUN npm ci --only=production --prefix backend
78

8-
COPY backend/ ./backend
9+
COPY backend ./backend
10+
RUN npm run build --prefix backend
911

1012
COPY frontend/package*.json ./frontend/
1113
RUN npm ci --only=production --prefix frontend
1214

13-
COPY frontend/ ./frontend
15+
COPY frontend ./frontend
16+
RUN npm run build --prefix frontend
1417

1518
ARG API_BASE_URL
1619
ENV API_BASE_URL=${API_BASE_URL}
@@ -19,4 +22,6 @@ RUN npm run build --prefix frontend
1922

2023
RUN rm -rf ./frontend/node_modules
2124

25+
COPY ./frontend/build /usr/share/nginx/html
26+
2227
CMD ["npm", "start", "--prefix", "backend"]

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"scripts": {
2323
"start": "react-scripts start",
24-
"build": "babel src -d build",
24+
"build": "react-scripts build",
2525
"test": "react-scripts test",
2626
"eject": "react-scripts eject"
2727
},

0 commit comments

Comments
 (0)