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

Publish official distroless images #2478

Merged
merged 3 commits into from
Apr 15, 2022
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
32 changes: 29 additions & 3 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
- linux/amd64
- linux/arm/v7
- linux/arm64
variant:
- alpine
- distroless
outputs:
version: ${{ steps.details.outputs.version }}

Expand All @@ -37,12 +40,17 @@ jobs:
*) VERSION=sha-${GITHUB_SHA::8};;
esac

VERSION_SUFFIX=""
if [[ "${{ matrix.variant }}" != "alpine" ]]; then
VERSION_SUFFIX="-${{ matrix.variant }}"
fi

TAGS=()
for image in $CONTAINER_IMAGES; do
TAGS+=("${image}:${VERSION}")
TAGS+=("${image}:${VERSION}${VERSION_SUFFIX}")

if [[ "${{ github.event.repository.default_branch }}" == "$VERSION" ]]; then
TAGS+=("${image}:latest")
TAGS+=("${image}:latest${VERSION_SUFFIX}")
fi
done

Expand Down Expand Up @@ -84,6 +92,7 @@ jobs:
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.details.outputs.tags }}
build-args: |
BASE_IMAGE=${{ matrix.variant }}
VERSION=${{ steps.details.outputs.version }}
COMMIT_HASH=${{ steps.details.outputs.commit_hash }}
BUILD_DATE=${{ steps.details.outputs.build_date }}
Expand All @@ -103,12 +112,29 @@ jobs:
runs-on: ubuntu-latest
needs: container-images
if: github.event_name == 'push'
strategy:
matrix:
variant:
- alpine
- distroless

steps:
# Workaround for lack of matrix output support
- name: Calculate container image details
id: details
run: |
VERSION="${{ needs.container-images.outputs.version }}"

if [[ "${{ matrix.variant }}" != "alpine" ]]; then
VERSION="${VERSION}-${{ matrix.variant }}"
fi

echo ::set-output name=version::${VERSION}

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.2.4
with:
image-ref: "ghcr.io/dexidp/dex:${{ needs.container-images.outputs.version }}"
image-ref: "ghcr.io/dexidp/dex:${{ steps.details.outputs.version }}"
format: "sarif"
output: "trivy-results.sarif"

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Docker

on:
push:
branches:
- master
tags:
- v[0-9]+.[0-9]+.[0-9]+
# push:
# branches:
# - master
# tags:
# - v[0-9]+.[0-9]+.[0-9]+
pull_request:

jobs:
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASEIMAGE=alpine:3.15.4
ARG BASE_IMAGE=alpine

FROM golang:1.17.8-alpine3.14 AS builder

Expand Down Expand Up @@ -40,8 +40,11 @@ RUN wget -O /usr/local/bin/gomplate \
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT}" \
&& chmod +x /usr/local/bin/gomplate

# For Dependabot to detect base image versions
FROM alpine:3.15.4 AS alpine
FROM gcr.io/distroless/static:latest AS distroless

FROM $BASEIMAGE
FROM $BASE_IMAGE

# Dex connectors, such as GitHub and Google logins require root certificates.
# Proper installations should manage those certificates, but it's a bad user
Expand Down