File size: 1,366 Bytes
d3acb8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bdea1d0
 
d3acb8a
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
# Stage 1: Build frontend
FROM node:18-alpine AS frontend-build
WORKDIR /build
COPY frontend/package*.json ./frontend/
COPY frontend/ ./
RUN npm ci
RUN npm run build

# Stage 2: Build backend
FROM python:3.11-slim AS backend-build
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH
WORKDIR /home/user/app
RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
COPY backend/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
COPY backend/ /home/user/app
COPY --from=frontend-build /build/dist /home/user/app/frontend_dist
RUN mkdir -p /data && chmod 700 /data
USER user
RUN pip install --no-cache-dir --upgrade pip

# Stage 3: Final image with nginx and supervisord
FROM python:3.11-slim
RUN apt-get update && apt-get install -y nginx supervisor gcc && rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH
WORKDIR /home/user/app
COPY --from=backend-build /home/user/app /home/user/app
COPY --from=backend-build /data /data
COPY nginx.conf /etc/nginx/nginx.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir -p /data && chmod 700 /data
USER user
EXPOSE 7860
## ENTRYPOINT removed: entrypoint.sh does not exist
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]