diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6780192 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.git +.gitignore +__pycache__/ +*.pyc +*.pyo +.pytest_cache/ +tests/ +docs/ +.coverage +*.egg-info/ +dist/ +build/ +*.egg +.env +.env.* +!.env.example diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dc62b6e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM python:3.11-slim AS builder + +WORKDIR /app + +COPY pyproject.toml README.md ./ +COPY src/ ./src/ + +RUN pip install --no-cache-dir --prefix=/install ".[server]" + +FROM python:3.11-slim AS runner + +WORKDIR /app + +ENV PYTHONUNBUFFERED=1 +ENV PYTHONDONTWRITEBYTECODE=1 + +COPY --from=builder /install /usr/local + +COPY pyproject.toml README.md ./ +COPY src/ ./src/ + +RUN addgroup --system --gid 1001 appuser \ + && adduser --system --uid 1001 appuser \ + && chown -R appuser:appuser /app + +USER appuser + +EXPOSE 8001 + +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8001/api/v1/health')" + +CMD ["uvicorn", "configs.geo_server:create_geo_app", "--factory", "--host", "0.0.0.0", "--port", "8001"]