aligned docker files

This commit is contained in:
Brian Bjarke Jensen
2025-11-06 21:34:04 +01:00
parent de13beb48b
commit 68aedc6f43
2 changed files with 32 additions and 7 deletions
+13 -5
View File
@@ -7,7 +7,8 @@ ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
UV_PROJECT_ENVIRONMENT=/app/.venv \
ENVIRONMENT=production
ENVIRONMENT=production \
DATA_DIR=/data
# Set working directory
WORKDIR /app
@@ -18,14 +19,18 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Copy dependency files
COPY pyproject.toml README.md ./
# Install Python dependencies
RUN uv sync --no-dev
# Copy application code
COPY src/ ./src/
# Install Python dependencies including all optional dependencies
# This makes the image self-contained and ready for any configuration
RUN uv sync --no-dev --all-extras
# Add virtual environment to PATH
ENV PATH="/app/.venv/bin:$PATH"
# Copy application code
COPY src/ ./src/
# Create data directory for SQLite database
RUN mkdir -p /data && chmod 777 /data
# Add healthcheck
HEALTHCHECK \
@@ -39,6 +44,9 @@ HEALTHCHECK \
# Expose port
EXPOSE 8000
# Declare volume for persistent data
VOLUME /data
# Set entrypoint to restrict usage to uvicorn with this specific app
ENTRYPOINT ["uvicorn", "src.baby_monitor.main:app"]
+19 -2
View File
@@ -1,5 +1,3 @@
version: "3.8"
services:
app:
build:
@@ -10,7 +8,26 @@ services:
volumes:
# Mount source code for hot-reloading during development
- ./src:/app/src:ro
# Persist database to local directory
- ./data:/data
environment:
- ENVIRONMENT=development
# Optional: Override admin credentials for development
# - ADMIN_USERNAME=admin
# - ADMIN_PASSWORD=devpassword
# Optional: Use Redis for token storage (uncomment redis service below)
# - REDIS_URI=redis://redis:6379/0
command: ["--host", "0.0.0.0", "--port", "8000", "--reload"]
restart: unless-stopped
# Uncomment to enable Redis token storage
# redis:
# image: redis:7-alpine
# ports:
# - "6379:6379"
# volumes:
# - redis-data:/data
# restart: unless-stopped
# Uncomment if using Redis
# volumes:
# redis-data: