Peiyan commited on
Commit
ae46fe5
·
verified ·
1 Parent(s): 8e7c163

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -5
Dockerfile CHANGED
@@ -2,25 +2,27 @@
2
  FROM node:14-bullseye-slim as build-step
3
  WORKDIR /app
4
  ENV PATH /app/node_modules/.bin:$PATH
5
- RUN mkdir ./frontend
 
6
  COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
7
  WORKDIR /app/frontend
8
  RUN npm install -g [email protected]
9
  RUN npm install
10
 
11
- WORKDIR /app
12
  COPY ./frontend ./frontend
13
-
14
  WORKDIR /app/frontend
15
  RUN npm run build
16
 
17
- FROM python:3.10.13-slim-bullseye
 
18
  RUN apt-get update && apt-get install -y nginx \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
  RUN python3 -m pip install --upgrade pip \
22
  && pip install gunicorn==20.1.0
23
 
 
24
  COPY ./backend ./backend
25
  RUN pip install -r ./backend/requirements.txt
26
 
@@ -30,7 +32,7 @@ RUN chmod -R 755 /var/log/nginx && \
30
  mkdir -p /var/lib/nginx/body && \
31
  chown -R root:root /var/log/nginx /var/lib/nginx /usr/share/nginx/html
32
 
33
- # Step #3: configure nginx and flask
34
  COPY --from=build-step /app/frontend/build /usr/share/nginx/html
35
  COPY deployment/docker/nginx.conf /etc/nginx/nginx.conf # Copy main nginx.conf
36
  COPY deployment/docker/serve.sh .
 
2
  FROM node:14-bullseye-slim as build-step
3
  WORKDIR /app
4
  ENV PATH /app/node_modules/.bin:$PATH
5
+
6
+ # Copy package.json and package-lock.json first to leverage Docker cache
7
  COPY ./frontend/package.json ./frontend/package-lock.json ./frontend/
8
  WORKDIR /app/frontend
9
  RUN npm install -g [email protected]
10
  RUN npm install
11
 
12
+ # Copy the rest of the frontend code and build the project
13
  COPY ./frontend ./frontend
 
14
  WORKDIR /app/frontend
15
  RUN npm run build
16
 
17
+ # Step #2: set up the Python backend and Nginx
18
+ FROM python:3.10.13-slim-bullseye
19
  RUN apt-get update && apt-get install -y nginx \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
  RUN python3 -m pip install --upgrade pip \
23
  && pip install gunicorn==20.1.0
24
 
25
+ # Copy backend code and install dependencies
26
  COPY ./backend ./backend
27
  RUN pip install -r ./backend/requirements.txt
28
 
 
32
  mkdir -p /var/lib/nginx/body && \
33
  chown -R root:root /var/log/nginx /var/lib/nginx /usr/share/nginx/html
34
 
35
+ # Step #3: configure Nginx and Flask
36
  COPY --from=build-step /app/frontend/build /usr/share/nginx/html
37
  COPY deployment/docker/nginx.conf /etc/nginx/nginx.conf # Copy main nginx.conf
38
  COPY deployment/docker/serve.sh .