-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathContainerfile.backend
More file actions
55 lines (41 loc) · 1.54 KB
/
Copy pathContainerfile.backend
File metadata and controls
55 lines (41 loc) · 1.54 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
51
52
53
54
55
# Ghost Backend Container
# FastAPI application serving the REST API
# Based on Red Hat Universal Base Image 9
FROM registry.access.redhat.com/ubi9/python-311:latest
# Labels for container metadata
LABEL name="ghost-backend" \
version="1.0.0" \
summary="Backend API for Ghost" \
description="FastAPI REST API for GitHub integration, activity tracking, and report generation" \
maintainer="Your Name <your.email@example.com>"
# Set working directory
WORKDIR /app
# Copy requirements first for better layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy source code
COPY src/ ./src/
# Create data directory for SQLite database (with proper permissions)
USER 0
RUN mkdir -p /app/data && chown -R 1001:0 /app/data && chmod -R g=u /app/data
USER 1001
# Set Python path to include src directory
ENV PYTHONPATH=/app/src
# Environment variables for configuration (override at runtime)
ENV DATABASE_URL="" \
GHOST_DATA_DIR="/app/data" \
DEV_MODE="false" \
CORS_ORIGINS="*"
# Expose the API port
EXPOSE 8000
# Volume for persistent data (SQLite database)
VOLUME ["/app/data"]
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')" || exit 1
# Run as non-root user
USER 1001
# Run uvicorn
CMD ["python", "-m", "uvicorn", "ghost.api.main:app", "--host", "0.0.0.0", "--port", "8000"]