-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
1c3b178
commit edb97d0
Showing
1 changed file
with
24 additions
and
25 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,30 +1,29 @@ | ||
# Use the official lightweight Python image. | ||
# https://hub.docker.com/_/python | ||
# ---- Base python ---- | ||
FROM python:3.9 AS base | ||
# Create app directory | ||
WORKDIR /app | ||
|
||
FROM python:buster | ||
# ---- Dependencies ---- | ||
FROM base AS dependencies | ||
COPY requirements.txt ./ | ||
# install app dependencies | ||
RUN pip install -r requirements.txt | ||
|
||
# Allow statements and log messages to immediately appear in the Knative logs | ||
ENV PYTHONUNBUFFERED True | ||
# ---- Copy Files/Build ---- | ||
FROM dependencies AS build | ||
WORKDIR /app | ||
COPY . /app | ||
# Build / Compile if required | ||
|
||
# Copy local code to the container image. | ||
ENV APP_HOME /app | ||
WORKDIR $APP_HOME | ||
COPY . ./ | ||
# --- Release with Alpine ---- | ||
FROM python:slim AS release | ||
# Create app directory | ||
WORKDIR /app | ||
|
||
# Install apt-utils | ||
#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils | ||
# Upgrade Linux packages | ||
RUN apt-get -y update && apt-get -y dist-upgrade && apt-get -y autoremove && apt-get -y autoclean | ||
# Upgrade pip itself | ||
RUN pip install --upgrade pip | ||
# Upgrade to latests python packages | ||
RUN pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U | ||
# Install dependencies | ||
RUN pip install -r requirements.txt | ||
COPY --from=dependencies /app/requirements.txt ./ | ||
COPY --from=dependencies /root/.cache /root/.cache | ||
|
||
# Run the web service on container startup. Here we use the gunicorn | ||
# webserver, with one worker process and 8 threads. | ||
# For environments with multiple CPU cores, increase the number of workers | ||
# to be equal to the cores available. | ||
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling. | ||
CMD exec gunicorn --bind :$PORT --workers 4 --worker-class uvicorn.workers.UvicornWorker --threads 8 --timeout 0 main:app | ||
# Install app dependencies | ||
RUN pip install -r requirements.txt | ||
COPY --from=build /app/ ./ | ||
CMD exec gunicorn --bind :$PORT --workers 4 --worker-class uvicorn.workers.UvicornWorker --threads 8 --timeout 0 main:app |