-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (37 loc) · 1.36 KB
/
Dockerfile
File metadata and controls
50 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# SDRF Validator API Dockerfile
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Copy requirements first for better caching
COPY requirements.txt .
# Cache-bust the pip install layer so unpinned VCS deps (sdrf-pipelines main HEAD)
# are re-fetched on every build. The CI pipeline passes the commit SHA here.
ARG CACHEBUST=dev
# Install Python dependencies. --upgrade ensures any unpinned VCS dep tracks main HEAD.
RUN echo "cachebust=$CACHEBUST" && pip install --upgrade --no-cache-dir -r requirements.txt
# Copy application code
COPY app.py .
COPY static ./static
# Create directory for temp files
RUN mkdir -p /tmp/sdrf-uploads && chown -R appuser:appuser /tmp/sdrf-uploads
# Switch to non-root user
USER appuser
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:5000/health || exit 1
# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "2"]