-
Notifications
You must be signed in to change notification settings - Fork 2
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
3 changed files
with
31 additions
and
46 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,28 +1,21 @@ | ||
# first stage | ||
FROM python:3.11.5-slim AS builder | ||
FROM python:3.12.2-slim-bookworm | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
COPY requirements.txt . | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests \ | ||
&& pip install --no-cache-dir --user -r requirements.txt \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# Create appuser and switch to it | ||
RUN useradd --create-home appuser | ||
USER appuser | ||
|
||
# Include the directory where python packages are installed in the PATH | ||
ENV PATH="/home/appuser/.local/bin:${PATH}" | ||
|
||
# final stage | ||
FROM python:3.11.5-slim | ||
# Set the working directory to a folder inside appuser's home directory | ||
WORKDIR /home/appuser/app | ||
|
||
# copy only the dependencies installation from the 1st stage image | ||
COPY --from=builder /root/.local /root/.local | ||
|
||
# update PATH environment variable | ||
ENV PATH=/root/.local/bin:$PATH | ||
|
||
WORKDIR /code | ||
# Install dependencies | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir --user -r requirements.txt | ||
|
||
COPY ./duckduckgo_search_api /code/duckduckgo_search_api | ||
# Copy the application code | ||
COPY ./duckduckgo_search_api /home/appuser/app/duckduckgo_search_api | ||
|
||
# Run the application | ||
CMD ["uvicorn", "duckduckgo_search_api.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "warning"] |
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
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,4 +1,4 @@ | ||
duckduckgo_search==3.9.9 | ||
fastapi==0.104.1 | ||
orjson==3.9.10 | ||
uvicorn[standard]==0.24.0 | ||
duckduckgo_search==5.1.0 | ||
fastapi==0.110.0 | ||
orjson==3.9.15 | ||
uvicorn[standard]==0.28.0 |