-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from OWASP/create-wolfi-docker-images
update dockerfiles for fixing CVEs in container images
- Loading branch information
Showing
4 changed files
with
112 additions
and
9 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
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
############################ | ||
# Builder Stage | ||
############################ | ||
# use chainguard hardened images with SBOM | ||
FROM cgr.dev/chainguard/wolfi-base as builder | ||
|
||
WORKDIR /offat | ||
|
||
ARG version=3.12 | ||
|
||
ENV LANG=C.UTF-8 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PATH="/offat/.venv/bin:$PATH" | ||
|
||
|
||
RUN apk add python-${version} py${version}-pip && \ | ||
chown -R nonroot.nonroot /offat | ||
|
||
# install poetry and copy lock file | ||
RUN python -m pip install poetry | ||
COPY pyproject.toml poetry.lock README.md ./ | ||
COPY offat ./offat | ||
|
||
# poetry config | ||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install -E api --without dev | ||
|
||
############################ | ||
# runtime stage | ||
############################ | ||
FROM cgr.dev/chainguard/wolfi-base as runtime | ||
|
||
WORKDIR /offat | ||
|
||
ARG version=3.12 | ||
|
||
ENV LANG=C.UTF-8 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV PATH="/offat/.venv/bin:$PATH" | ||
ENV VIRTUAL_ENV=/offat/.venv | ||
|
||
RUN apk add python-${version} py${version}-pip && \ | ||
chown -R nonroot.nonroot /offat | ||
|
||
|
||
# copy venv from builder image | ||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
|
||
# copy necessary files | ||
COPY offat ./offat | ||
COPY README.md CODE_OF_CONDUCT.md DISCLAIMER.md pyproject.toml . | ||
|
||
USER nonroot |
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,3 +1,11 @@ | ||
build-local-images: | ||
build-slim-local-images: | ||
@docker build -f DockerFiles/base-Dockerfile -t dmdhrumilmistry/offat-base . | ||
@docker build -f DockerFiles/cli-Dockerfile -t dmdhrumilmistry/offat . | ||
# @docker build -f DockerFiles/main/cli-Dockerfile -t dmdhrumilmistry/offat . | ||
|
||
build-local-image: | ||
@docker build -f DockerFiles/wolfi-base-Dockerfile -t dmdhrumilmistry/offat-base . --no-cache --progress=plain | ||
|
||
scan-vulns: | ||
@trivy image dmdhrumilmistry/offat-base --scanners vuln | ||
|
||
local: build-local-image scan-vulns |