Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change alpine version + Fix CVE-2023-4236{4,5} #26

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 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,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/github-actions-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ jobs:
runs-on: "ubuntu-20.04"
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0

- name: Build an image from Dockerfile
run: |
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe
uses: aquasecurity/trivy-action@0.22.0
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'template'
template: '@/contrib/sarif.tpl'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
config.yaml
*__pycache__*
*.dat
dist/
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 git \
# 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-dynamic-versioning[plugin]==v1.3.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"]
5 changes: 4 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,6 @@ pytest-mock = "^3.14.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry-dynamic-versioning]
enable = true
Loading