File size: 1,273 Bytes
2655a7f
 
 
 
 
8b6f0fd
d091da8
2655a7f
31afc96
2655a7f
 
eb1abc7
 
31afc96
eb1abc7
 
 
 
 
31afc96
eb1abc7
a624c63
31afc96
 
 
46647de
 
 
 
 
2655a7f
 
 
 
 
 
c371e15
 
 
2655a7f
 
 
 
 
 
 
 
 
 
46647de
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
49
50
FROM node:18 as client-build
WORKDIR /app
COPY client/package*.json ./
RUN npm install
COPY client/ ./
ENV VITE_API_URL=https://mistral-ai-game-jam-dont-lookup.hf.space
RUN mkdir -p dist && npm run build

FROM python:3.10-slim
WORKDIR /app

# Create non-root user
RUN useradd -m -u 1000 user

# Install system dependencies and poetry
RUN apt-get update && apt-get install -y \
    netcat-openbsd \
    && rm -rf /var/lib/apt/lists/* \
    && pip install poetry

# Copy and install Python dependencies
COPY server/pyproject.toml server/poetry.lock* ./
RUN poetry config virtualenvs.create false \
    && poetry install --no-interaction --no-ansi --only main --no-root

# Copy server code to the root directory to maintain import structure
COPY server/* ./
COPY server/core ./core
COPY server/api ./api
COPY server/services ./services

# Copy client build
COPY --from=client-build /app/dist ./static

# Environment variables
ENV API_HOST=0.0.0.0 \
    API_PORT=7860 \
    STATIC_FILES_DIR=static \
    DOCKER_ENV=true

# Create cache directory and set permissions
RUN mkdir -p /app/cache && chown -R user:user /app/cache

# Switch to non-root user
USER user

EXPOSE 7860

# Start the server
CMD ["python", "-m", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]