Files
kursy-mirror/Dockerfile

58 lines
1.1 KiB
Docker

FROM python:3.14-slim-bookworm AS builder
RUN useradd -m kursy
ENV NODE_VERSION=24.14.1
# install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# install nodejs
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs
# copy project files
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN chown kursy:kursy /app -R
USER kursy
# install project dependencies
RUN uv sync
COPY --chown=kursy:kursy . .
# install tailwind
WORKDIR /app/theme/static_src
RUN npm install
# collect static files
WORKDIR /app
RUN uv run python manage.py collectstatic --noinput --clear
# --- RUNTIME IMAGE ---
FROM python:3.14-slim-bookworm
RUN useradd -m kursy
WORKDIR /app
RUN mkdir -p /app/data && chown kursy:kursy /app/data
USER kursy
COPY --from=builder --chown=kursy:kursy /app/.venv /app/.venv
COPY --from=builder --chown=kursy:kursy /app /app
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PORT=8000
EXPOSE 8000
CMD set -xe; python manage.py migrate --noinput; python manage.py runserver 0.0.0.0:8000