Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Multi-stage Dockerfile for Python Template Server
# Stage 1: Build stage - build wheel using uv
FROM python:3.12-slim AS builder

WORKDIR /build

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Copy project files
COPY python_template_server/ ./python_template_server/
COPY configuration ./configuration/
COPY pyproject.toml .here LICENSE README.md ./

# Build the wheel
RUN uv build --wheel

# Stage 2: Runtime stage
FROM python:3.12-slim

# Build arguments for environment-specific config
Expand All @@ -10,14 +28,15 @@ WORKDIR /app
RUN useradd -m -u 1000 template_server_user && \
chown -R template_server_user:template_server_user /app

# Install Git for dependency resolution
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

# Install uv in runtime stage
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Install dependencies
RUN uv pip install --system git+https://github.com/javidahmed64592/python-template-server.git
# Copy the built wheel from builder
COPY --from=builder /build/dist/*.whl /tmp/

# Install the wheel
RUN uv pip install --system --no-cache /tmp/*.whl && \
rm /tmp/*.whl

# Create configuration directory
RUN mkdir -p /app/configuration && \
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ python-template-server = "python_template_server.main:run"
generate-certificate = "python_template_server.certificate_handler:generate_self_signed_certificate"
generate-new-token = "python_template_server.authentication_handler:generate_new_token"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build]
include = [
"configuration/**",
Expand Down