-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
37 lines (27 loc) · 1.08 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Use an official Python runtime as a parent image - Use the latest slim version as the base image
FROM python:3.12-slim
# Set arguments to be passed from build-args
ARG VERSION
# Set the working directory in the container
WORKDIR /app
# Copy pyproject.toml and any other configuration (optional)
COPY pyproject.toml /app/
# Install pip-tools and use it to resolve dependencies
RUN pip install --no-cache-dir pip-tools \
&& pip-compile --generate-hashes \
&& pip-sync
# Curl installation step for health check
RUN apt-get update && apt-get install -y curl
# Copy the rest of the application source code into the container
COPY ./src /app/src
COPY ./config /app/config
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app/src
ENV APP_VERSION=$VERSION
# Expose port 8000 for the FastAPI Borehole app
EXPOSE 8000
# Run a health check to ensure the container is healthy
HEALTHCHECK CMD curl --silent --fail http://localhost:8000/health || exit 1
# Command to run the FastAPI Borehole app with Uvicorn
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]