Skip to content

Commit f2241b8

Browse files
author
Tom Softreck
committed
update structure
1 parent 7feb23d commit f2241b8

File tree

14 files changed

+4232
-7
lines changed

14 files changed

+4232
-7
lines changed

Dockerfile

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,72 @@
1-
# Container support
1+
# Multi-stage build for TaskProvision
2+
FROM python:3.11-slim as builder
3+
4+
# Set environment variables
5+
ENV PYTHONUNBUFFERED=1 \
6+
PYTHONDONTWRITEBYTECODE=1 \
7+
PIP_NO_CACHE_DIR=1 \
8+
PIP_DISABLE_PIP_VERSION_CHECK=1
9+
10+
# Install system dependencies
11+
RUN apt-get update && apt-get install -y \
12+
build-essential \
13+
curl \
14+
git \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Create and switch to app user
18+
RUN groupadd -r taskprovision && useradd -r -g taskprovision taskprovision
19+
RUN mkdir -p /app && chown taskprovision:taskprovision /app
20+
21+
# Set work directory
22+
WORKDIR /app
23+
24+
# Copy requirements first for better caching
25+
COPY requirements.txt requirements-dev.txt ./
26+
RUN pip install --no-cache-dir -r requirements.txt
27+
28+
# Production stage
29+
FROM python:3.11-slim as production
30+
31+
# Set environment variables
32+
ENV PYTHONUNBUFFERED=1 \
33+
PYTHONDONTWRITEBYTECODE=1 \
34+
PATH="/app/venv/bin:$PATH" \
35+
ENVIRONMENT=production
36+
37+
# Install runtime dependencies
38+
RUN apt-get update && apt-get install -y \
39+
curl \
40+
git \
41+
&& rm -rf /var/lib/apt/lists/*
42+
43+
# Create app user
44+
RUN groupadd -r taskprovision && useradd -r -g taskprovision taskprovision
45+
46+
# Create directories
47+
RUN mkdir -p /app /app/logs /app/uploads && \
48+
chown -R taskprovision:taskprovision /app
49+
50+
# Copy Python packages from builder
51+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
52+
COPY --from=builder /usr/local/bin /usr/local/bin
53+
54+
# Switch to app user
55+
USER taskprovision
56+
WORKDIR /app
57+
58+
# Copy application code
59+
COPY --chown=taskprovision:taskprovision . .
60+
61+
# Install TaskProvision in development mode
62+
RUN pip install -e .
63+
64+
# Expose port
65+
EXPOSE 8000
66+
67+
# Health check
68+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
69+
CMD curl -f http://localhost:8000/health || exit 1
70+
71+
# Start command
72+
CMD ["uvicorn", "taskprovision.main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)