-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(bot): change Docker base image to python:3.7-slim (#796)
While scanning the Kodiak Docker image with [Grype](https://github.com/anchore/grype), we noticed a significant amount of vulnerabilities. This PR upgrade the base image to the latest 3.7 image and use the slim version which come with a smaller size and reduce the attack surface. I also took the opportunity to use a non root user. - previously: image size 1.31GB, 3694 vulnerabilities - now: image size 607Mb, 87 vulnerabilities
- Loading branch information
1 parent
a16e7ba
commit 729e64d
Showing
3 changed files
with
31 additions
and
23 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
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,32 +1,32 @@ | ||
FROM python:3.7@sha256:6eaf19442c358afc24834a6b17a3728a45c129de7703d8583392a138ecbdb092 | ||
FROM python:3.7-slim | ||
|
||
RUN apt update && \ | ||
apt-get install --no-install-recommends -y \ | ||
supervisor \ | ||
git && \ | ||
python -m pip install --upgrade pip && \ | ||
pip install \ | ||
--no-cache-dir \ | ||
--root-user-action=ignore \ | ||
cryptography===37.0.4 \ | ||
poetry===1.1.15 && \ | ||
poetry config virtualenvs.in-project true && \ | ||
groupadd kodiak && \ | ||
useradd --uid 1000 --gid kodiak kodiak && \ | ||
mkdir -p /var/app && \ | ||
chown -R kodiak:kodiak /var/app | ||
|
||
RUN set -ex && mkdir -p /var/app | ||
|
||
RUN apt-get update && apt-get install -y supervisor | ||
|
||
RUN mkdir -p /var/log/supervisor | ||
|
||
# use cryptography version for poetry that doesn't require Rust | ||
RUN python3 -m pip install cryptography===37.0.4 | ||
RUN python3 -m pip install poetry===1.1.13 | ||
|
||
RUN poetry config virtualenvs.in-project true | ||
WORKDIR /var/app | ||
|
||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
|
||
WORKDIR /var/app | ||
|
||
COPY pyproject.toml poetry.lock /var/app/ | ||
COPY --chown=kodiak pyproject.toml poetry.lock ./ | ||
|
||
# install deps | ||
RUN poetry install | ||
|
||
COPY . /var/app | ||
COPY --chown=kodiak . ./ | ||
|
||
# workaround for: https://github.com/sdispater/poetry/issues/1123 | ||
RUN rm -rf /var/app/pip-wheel-metadata/ | ||
|
||
# install cli | ||
RUN poetry install | ||
USER kodiak | ||
|
||
CMD ["/usr/bin/supervisord"] |
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,12 +1,15 @@ | ||
[supervisord] | ||
nodaemon=true | ||
user=kodiak | ||
|
||
[program:ingest] | ||
command=/var/app/.venv/bin/python -m kodiak.entrypoints.ingest | ||
stdout_logfile=/dev/stdout | ||
stderr_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
|
||
[program:worker] | ||
command=/var/app/.venv/bin/python -m kodiak.entrypoints.worker | ||
stdout_logfile=/dev/stdout | ||
stderr_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 |