create docker compose setup
This commit is contained in:
parent
f2fd4c8d7c
commit
16e840fb78
9 changed files with 228 additions and 46 deletions
46
Dockerfile
Normal file
46
Dockerfile
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# Use Python 3.13 slim image
|
||||
FROM python:3.13-slim
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies and build tools
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
gcc \
|
||||
g++ \
|
||||
build-essential \
|
||||
python3-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Hatch
|
||||
RUN pip install --no-cache-dir hatch
|
||||
|
||||
# Copy project files
|
||||
COPY pyproject.toml ./
|
||||
COPY LICENSE ./
|
||||
COPY README.md ./
|
||||
COPY src/ ./src/
|
||||
|
||||
# Install project and dependencies using Hatch
|
||||
RUN hatch build -t wheel && \
|
||||
pip install --no-cache-dir dist/*.whl && \
|
||||
rm -rf dist/ build/
|
||||
|
||||
# Create non-root user for security
|
||||
RUN useradd --create-home --shell /bin/bash app \
|
||||
&& chown -R app:app /app
|
||||
USER app
|
||||
|
||||
# Set environment variable to indicate container environment
|
||||
ENV DOCKER_CONTAINER=1
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/ || exit 1
|
||||
|
||||
# Run the application
|
||||
CMD ["uvicorn", "random_access.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue