File size: 1,194 Bytes
c89a139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Stage 1: Build React Frontend
FROM node:18-slim as build
WORKDIR /app
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm install

# Force rebuild of frontend
ARG CACHE_BUST=v14
COPY frontend/ .
RUN npm run build

# Stage 2: Python Backend
FROM python:3.9-slim

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Set up persistent data directory (as root)
ENV DATA_DIR=/data
RUN mkdir -p $DATA_DIR && chown -R user:user $DATA_DIR && chmod 777 $DATA_DIR

# SwitchRUN echo "Cache Buster: v19" user
USER user

# Set home to the user's home directory
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app

# Force frontend rebuild
ARG CACHE_BUST=v2
COPY --from=build --chown=user /app/dist $HOME/app/frontend/dist

# Install requirements
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Command to run the application
CMD sh -c "echo 'Starting HHeuristics v2.1...' && uvicorn app:app --host 0.0.0.0 --port 7860 --workers 1"