doker use appuser + health check

This commit is contained in:
dm
2025-08-27 10:53:10 +03:00
parent 2de17b1a8b
commit fad9d6a183
2 changed files with 15 additions and 8 deletions

View File

@@ -5,15 +5,19 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
&& ln -s /root/.local/bin/uv /usr/local/bin/uv
ENV XDG_CACHE_HOME=/root/.cache \
UV_CACHE_DIR=/root/.cache/uv \
UV_LINK_MODE=copy \
PYTHONUNBUFFERED=1
&& cp /root/.local/bin/uv /usr/local/bin/uv
WORKDIR /app
RUN useradd --create-home appuser \
&& chown -R appuser:appuser /app
USER appuser
ENV XDG_CACHE_HOME=/home/appuser/.cache \
UV_CACHE_DIR=/home/appuser/.cache/uv \
UV_LINK_MODE=copy \
PYTHONUNBUFFERED=1
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev
@@ -21,3 +25,6 @@ COPY . .
EXPOSE 8000
CMD ["uv", "run", "uvicorn", "app.api:app", "--host", "0.0.0.0", "--port", "8000"]
HEALTHCHECK --interval=30s --timeout=10s \
CMD curl -f http://localhost:8000/healthchecker

View File

@@ -88,5 +88,5 @@ async def get_list_of_files(api_key: str = Depends(verify_api_key)):
]
@app.get("/healthchecker")
async def healthchecker(api_key: str = Depends(verify_api_key)):
return {"message": "Howdy :3"}
async def healthchecker():
return {"message": "Howdy, all is fine :3"}