forked from sr2/cloud-api
feat: adds Containerfile with frontend serving
This commit is contained in:
parent
c28b4dc37b
commit
9e1d6026b5
5 changed files with 56 additions and 7 deletions
42
Containerfile
Normal file
42
Containerfile
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
FROM node:22-slim AS react-builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY frontend/ /app/
|
||||
RUN --mount=type=cache,target=/root/.npm npm ci
|
||||
RUN npm run build # Outputs to /app/dist
|
||||
|
||||
FROM ghcr.io/astral-sh/uv:python3.12-trixie-slim AS python-builder
|
||||
|
||||
ENV UV_PYTHON_DOWNLOADS=0
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies first (layer caching)
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
--mount=type=bind,source=uv.lock,target=uv.lock \
|
||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||
uv sync --locked --no-install-project --no-editable
|
||||
|
||||
# Copy project source and install the project itself
|
||||
COPY ./ /app/
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --locked --no-editable
|
||||
|
||||
|
||||
FROM python:3.12-slim-trixie
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY alembic /app/alembic
|
||||
COPY alembic.ini /app
|
||||
COPY src /app/src
|
||||
COPY --from=python-builder /app/.venv /app/.venv
|
||||
COPY --from=react-builder /app/dist /app/static
|
||||
|
||||
# Ensure venv is on PATH
|
||||
ENV PATH="/app/.venv/bin:$PATH" \
|
||||
UV_PYTHON_DOWNLOADS=0
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue