From 3002990e43fcbf69bb2a4aa81e9726337b057f61 Mon Sep 17 00:00:00 2001 From: brb Date: Mon, 10 Jul 2023 16:46:46 +0200 Subject: [PATCH] defined build of container --- Dockerfile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5cef9ae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,49 @@ +########### +# BUILDER # +########### + +# pull official base image +FROM python:3.10-bookworm as BUILDER + +# install Ookla's speedtest +RUN apt update && \ + apt install -y speedtest-cli + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# install dependencies +WORKDIR /usr/src/app +COPY requirements.txt . +RUN pip install --upgrade pip && \ + pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt + +######### +# FINAL # +######### + +FROM python:3.10-bookworm + +# create home direcroty and app user +RUN mkdir -p /home/app && \ + addgroup --system app && \ + adduser --system --group app + +# install packages from builder +COPY --from=BUILDER /usr/src/app/wheels /wheels +COPY --from=BUILDER /usr/src/app/requirements.txt requirements.txt +RUN pip install --no-cache /wheels/* + +# copy in files +WORKDIR /home/app +COPY ./code . + +# change ownership to app user +RUN chown -R app:app /home/app + +# change to the app user +USER app + +# start execution +ENTRYPOINT [ "python", "main.py" ] \ No newline at end of file