mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
25 lines
600 B
Docker
25 lines
600 B
Docker
# 1. Install pip dependencies
|
|
FROM python:3.12 AS builder
|
|
|
|
WORKDIR /app
|
|
RUN python3 -m venv .venv
|
|
COPY backend/requirements.txt .
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
./.venv/bin/pip3 install -r requirements.txt
|
|
|
|
# 2. Runtime stage
|
|
FROM python:3.12-slim AS runtime
|
|
|
|
# 2.1. Non-root user
|
|
WORKDIR /app
|
|
RUN useradd -u 1000 app && \
|
|
chown -R app /app
|
|
USER app
|
|
|
|
# 2.2. Copy content and create dirs
|
|
COPY --chown=app backend .
|
|
COPY --from=builder --chown=app /app/.venv .venv
|
|
RUN mkdir -p /app/data
|
|
|
|
# 3. Final command
|
|
ENTRYPOINT exec ./.venv/bin/fastapi run --port ${PORT:-8300} main.py |