-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathWebApp.Dockerfile
More file actions
48 lines (37 loc) · 1.29 KB
/
WebApp.Dockerfile
File metadata and controls
48 lines (37 loc) · 1.29 KB
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
# Stage 1: Build frontend
FROM node:20-alpine AS frontend
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
# Install dependencies
COPY ./frontend/package*.json ./
USER node
RUN npm ci
# Copy source code and build
COPY --chown=node:node ./frontend/ ./frontend
WORKDIR /home/node/app/frontend
RUN npm run build
# Stage 2: Build backend with static files
FROM python:3.11-alpine
# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
build-base \
libffi-dev \
openssl-dev \
curl \
&& apk add --no-cache \
libpq
COPY requirements.txt /usr/src/app/
RUN pip install --upgrade pip setuptools wheel \
&& pip install --no-cache-dir -r /usr/src/app/requirements.txt \
&& rm -rf /root/.cache
# Copy backend source code
COPY . /usr/src/app/
# Copy static files from the frontend stage to the backend
COPY --from=frontend /home/node/app/frontend/build/index.html /usr/src/app/static/
COPY --from=frontend /home/node/app/frontend/build/favicon.ico /usr/src/app/static/
COPY --from=frontend /home/node/app/frontend/build/static /usr/src/app/static/
# Set working directory and expose port
WORKDIR /usr/src/app
EXPOSE 80
# Start application
CMD ["gunicorn", "-b", "0.0.0.0:80", "app:app"]