Skip to content

Commit

Permalink
Change alpine version + Fix CVE-2023-42364,CVE-2023-42364
Browse files Browse the repository at this point in the history
  • Loading branch information
LawiK974 committed Jun 13, 2024
1 parent 7bb742e commit 21b3977
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/github-actions-docker-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/github-actions-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
runs-on: "ubuntu-20.04"
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Build an image from Dockerfile
run: |
Expand Down
22 changes: 15 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
# Stage 1: Builder stage where the package is built using Poetry
FROM python:3.12-alpine as builder
FROM python:alpine3.20 as builder

WORKDIR /app
RUN apk add gcc libc-dev libffi-dev
RUN pip install poetry
RUN apk update \
# Install poetry dependencies
&& apk add gcc libc-dev libffi-dev \
# Fix CVE-2023-42364
&& apk upgrade busybox \
# Clean cache
&& apk cache clean
RUN pip install poetry==1.8.3
COPY . /app
# Disable virtual env creation by poetry, it's not needed in Docker
RUN poetry config virtualenvs.create false
# Install poetry version plugin see https://github.com/tiangolo/poetry-version-plugin
RUN poetry self add poetry-version-plugin==0.2.0
# Install dependencies only (to improve caching)
RUN poetry install --no-root --no-dev
RUN poetry install --no-root --only main
# Build the package (this creates the package wheel)
RUN poetry build

# Stage 2: Lightweight production stage with minimal footprint
FROM python:3.12-alpine as production
FROM python:alpine3.20 as production
WORKDIR /app
COPY --from=builder /app/dist/*.whl /app/
RUN pip install --no-cache-dir /app/*.whl
COPY --from=builder /app/dist/*.whl /tmp/
RUN pip install --no-cache-dir /tmp/*.whl && rm -rf /tmp/*.whl
ENV PYTHONUNBUFFERED=1
CMD ["kube-notify", "--config", "/app/config.yaml", "--inCluster"]
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "kube-notify"
version = "0.1.1"
version = "0"
description = "A simple python app to relay k8s events to gotify"
authors = ["wikle <loic97429@gmail.com>"]
license = "MIT"
Expand Down Expand Up @@ -28,3 +28,7 @@ pytest-mock = "^3.14.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"


[tool.poetry-version-plugin]
source = "git-tag"

0 comments on commit 21b3977

Please sign in to comment.