Files
ObsiGate/Dockerfile
T
bruno a80df670be
CI / lint (push) Failing after 9s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / e2e (push) Has been skipped
CI / security (push) Successful in 17s
Desktop Build / build-windows (push) Has been cancelled
Desktop Build / build-linux (push) Has been cancelled
fix: version Docker — générer VERSION file depuis .git/HEAD au build
- Dockerfile: COPY .git/HEAD + .git/refs/ → génère backend/VERSION avec hash
- version.py: fallback lit backend/VERSION (à côté du module, pas racine repo)
- Format: 1.8.0-0-g<8-char-hash> ou 1.8.0-dev si indisponible
2026-07-27 17:17:47 -04:00

63 lines
2.1 KiB
Docker

# ObsiGate — Multi-platform Docker image
# Stage 1: Install Python dependencies (with build tools)
FROM python:3.11-slim AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc libffi-dev libc6-dev libpango-1.0-0 libpangocairo-1.0-0 shared-mime-info \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY backend/requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# Stage 2: Final lightweight image (no build tools)
FROM python:3.11-slim
LABEL maintainer="Bruno Beloeil" \
version="1.4.0" \
description="ObsiGate — lightweight web interface for Obsidian vaults"
WORKDIR /app
# Copy installed packages from builder stage
COPY --from=builder /install /usr/local
# WeasyPrint runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpango-1.0-0 libpangocairo-1.0-0 shared-mime-info \
&& rm -rf /var/lib/apt/lists/*
# Copy application code
COPY backend/ ./backend/
COPY frontend/ ./frontend/
# Generate VERSION file from git (fallback for version.py when .git is not available)
COPY .git/HEAD .git/refs/ /tmp/git-refs/
RUN cd /tmp/git-refs && \
if [ -f HEAD ]; then \
REF=$(cat HEAD | awk '{print $2}'); \
if [ -f "$REF" ]; then \
HASH=$(cat "$REF" | head -c 8); \
echo "1.8.0-0-g${HASH}" > /app/backend/VERSION; \
else \
echo "1.8.0-dev" > /app/backend/VERSION; \
fi; \
else \
echo "1.8.0-dev" > /app/backend/VERSION; \
fi && \
rm -rf /tmp/git-refs
# Create non-root user for security + data directory for auth persistence
# Using explicit UID/GID 1000 to match common host user and docker-compose settings
RUN groupadd -g 1000 obsigate && useradd -u 1000 -g obsigate -d /app -s /sbin/nologin obsigate \
&& mkdir -p /app/data \
&& chown -R obsigate:obsigate /app
USER obsigate
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/api/health')" || exit 1
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8080"]