From 6f624ecb7bdba26b5491762baaaaec68a8019af6 Mon Sep 17 00:00:00 2001 From: Tomislav Mikulin Date: Sun, 2 Jan 2022 16:32:52 +0100 Subject: [PATCH 1/2] optimize the dockerfile with security and shrinking the resulting docker image --- Dockerfile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 569df05..050714f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,29 @@ -FROM python:3.9 +FROM python:3.9-slim-buster -RUN pip install -U pip \ +ENV POETRY_VERSION=1.1.12 + +RUN useradd --create-home flashbot \ && apt-get update \ - && curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - + && apt-get install -y --no-install-recommends build-essential libffi-dev libpq-dev gcc procps \ + && pip install poetry==$POETRY_VERSION \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* -ENV PATH="${PATH}:/root/.poetry/bin" +ENV PATH="${PATH}:/home/flashbot/.local/bin" -COPY ./pyproject.toml /app/pyproject.toml -COPY ./poetry.lock /app/poetry.lock +COPY --chown=flashbot ./pyproject.toml /app/pyproject.toml +COPY --chown=flashbot ./poetry.lock /app/poetry.lock WORKDIR /app/ -RUN poetry config virtualenvs.create false && \ - poetry install +USER flashbot -COPY . /app +RUN poetry config virtualenvs.create false \ + && poetry install -# easter eggs 😝 -RUN echo "PS1='🕵️:\[\033[1;36m\]\h \[\033[1;34m\]\W\[\033[0;35m\]\[\033[1;36m\]$ \[\033[0m\]'" >> ~/.bashrc +COPY --chown=flashbot . /app + +# easter eggs +RUN echo "PS1='️ :\[\033[1;36m\]\h \[\033[1;34m\]\W\[\033[0;35m\]\[\033[1;36m\]$ \[\033[0m\]'" >> ~/.bashrc ENTRYPOINT [ "poetry" ] CMD [ "run", "python", "loop.py" ] From 9ab1e6e5b14055a47df297ab676969237e692cea Mon Sep 17 00:00:00 2001 From: Tomislav Mikulin Date: Fri, 7 Jan 2022 09:25:30 +0100 Subject: [PATCH 2/2] add the missing emojis --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 050714f..7c27962 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,8 @@ RUN poetry config virtualenvs.create false \ COPY --chown=flashbot . /app -# easter eggs -RUN echo "PS1='️ :\[\033[1;36m\]\h \[\033[1;34m\]\W\[\033[0;35m\]\[\033[1;36m\]$ \[\033[0m\]'" >> ~/.bashrc +# easter eggs 😝 +RUN echo "PS1='🕵️:\[\033[1;36m\]\h \[\033[1;34m\]\W\[\033[0;35m\]\[\033[1;36m\]$ \[\033[0m\]'" >> ~/.bashrc ENTRYPOINT [ "poetry" ] CMD [ "run", "python", "loop.py" ]