Skip to content

Instantly share code, notes, and snippets.

@MwinyiMoha
Last active November 5, 2020 16:49
Show Gist options
  • Save MwinyiMoha/2a233fea690fab597dfca44e9bf096b5 to your computer and use it in GitHub Desktop.
Save MwinyiMoha/2a233fea690fab597dfca44e9bf096b5 to your computer and use it in GitHub Desktop.
ARG PORT=5000
FROM python:3.8-slim-buster
LABEL maintainer="Mohammed Mwijaa<mm.mwijaa@gmail.com>"
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
RUN apt-get update && \
apt-get -y upgrade && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN groupadd appusers && \
useradd -mg appusers -s /bin/sh app
RUN mkdir -p /home/app/src && \
chown -R app:appusers /home/app/src
WORKDIR /home/app/src
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
USER app
COPY --chown=app:appusers . .
EXPOSE ${PORT}
ENTRYPOINT gunicorn \
app.main:app \
-w 3 \
-k uvicorn.workers.UvicornWorker \
--max-requests 1024 \
--max-requests-jitter 100 \
--worker-tmp-dir /dev/shm \
--access-logfile=- \
--log-file=- \
-b 0.0.0.0:${PORT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment