-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,37 @@ | ||
FROM python:3.12-slim | ||
# Use Python 3.12 Alpine as the base image | ||
FROM python:3.12-alpine | ||
|
||
# Set up build argument and environment variable for branch name | ||
ARG BRANCH_NAME=main | ||
ENV BRANCH_NAME=${BRANCH_NAME} | ||
|
||
# Set the Tini version | ||
ENV TINI_VERSION=v0.19.0 | ||
|
||
# Set up build argument and environment variable for config directory | ||
ARG CONFIG_DIR=/config | ||
ENV CONFIG_DIR=/config | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the requirements file into the container | ||
COPY requirements.txt / | ||
|
||
# install packages | ||
RUN echo "**** install system packages ****" \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
git \ | ||
bash \ | ||
curl \ | ||
wget \ | ||
jq \ | ||
grep \ | ||
sed \ | ||
coreutils \ | ||
findutils \ | ||
gcc \ | ||
libffi-dev \ | ||
rustc \ | ||
cargo \ | ||
tini \ | ||
&& pip3 install --no-cache-dir --upgrade pip \ | ||
&& pip3 install --no-cache-dir --upgrade --requirement /requirements.txt \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /requirements.txt /tmp/* /var/tmp/* | ||
|
||
COPY . . | ||
# Install necessary system dependencies and Tini | ||
RUN apk add --no-cache gcc musl-dev libffi-dev tini | ||
|
||
# Copy the rest of the application code into the container | ||
COPY . . | ||
|
||
# Install Python dependencies | ||
RUN pip install --no-cache-dir --upgrade -r /requirements.txt && pip install -e . | ||
|
||
# Create a volume for the config directory | ||
VOLUME /config | ||
|
||
# Expose port 8000 for the FastAPI application | ||
EXPOSE 8000 | ||
ENTRYPOINT ["/sbin/tini", "-s", "/app/copy-config.sh", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] | ||
|
||
# Set the entrypoint to run the application using Tini as the init process | ||
ENTRYPOINT ["/sbin/tini", "-s", "--", "/app/copy-config.sh", "fastapi", "run", "main.py", "--host", "0.0.0.0", "--port", "8000"] |