Skip to content

Commit cdfcc2d

Browse files
committed
build multiple alpine images
1 parent 78b78f5 commit cdfcc2d

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

.github/workflows/ci.yml

+12-8
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ env:
1616
jobs:
1717
build:
1818
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
image: ["3.17", "3.19", "3.20"]
22+
openssl_version: ["3.0.9"]
1923
steps:
2024
- name: Checkout Repository
2125
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
2226

23-
- name: Get Alpine version
24-
id: alpine
25-
run: echo "version=$(grep -m1 'FROM alpine' <Dockerfile | awk -F'[:]' '{print $2}')" >> $GITHUB_OUTPUT
26-
2727
- name: Docker Buildx
2828
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
2929

@@ -52,7 +52,7 @@ jobs:
5252
type=ref,event=pr
5353
type=semver,pattern={{version}}
5454
type=semver,pattern={{major}}.{{minor}}
55-
type=semver,pattern={{version}},suffix=-alpine${{ steps.alpine.outputs.version }}
55+
type=semver,pattern={{version}},suffix=-alpine${{ matrix.image }}
5656
env:
5757
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
5858

@@ -62,23 +62,27 @@ jobs:
6262
with:
6363
file: Dockerfile
6464
context: "."
65-
cache-from: type=gha,scope=alpine
66-
cache-to: type=gha,scope=alpine,mode=max
65+
cache-from: type=gha,scope=alpine${{ matrix.image }}
66+
cache-to: type=gha,scope=alpine${{ matrix.image }},mode=max
6767
tags: ${{ steps.meta.outputs.tags }}
6868
load: ${{ github.event_name == 'pull_request' }}
6969
push: ${{ github.event_name != 'pull_request' }}
7070
platforms: ${{ github.event_name != 'pull_request' && env.platforms || '' }}
7171
annotations: ${{ github.event_name != 'pull_request' && steps.meta.outputs.annotations || '' }}
72+
target: alpine
7273
pull: true
7374
sbom: ${{ github.event_name != 'pull_request' }}
7475
provenance: ${{ github.event_name != 'pull_request' }}
76+
build-args: |
77+
BUILD_OS=alpine:${{ matrix.image }}
78+
OPENSSL_VERSION=${{ matrix.openssl_version }}
7579
7680
- name: Run Grype vulnerability scanner
7781
uses: anchore/scan-action@3343887d815d7b07465f6fdcd395bd66508d486a # v3.6.4
7882
continue-on-error: true
7983
id: scan
8084
with:
81-
image: ghcr.io/nginxinc/alpine-fips:${{ steps.meta.outputs.version }}
85+
image: ghcr.io/nginxinc/alpine-fips:${{ steps.meta.outputs.version }}-alpine${{ matrix.image }}
8286
only-fixed: true
8387
add-cpes-if-none: true
8488

Dockerfile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
FROM alpine:3.19
2-
1+
# syntax=docker/dockerfile:1.6
2+
ARG BUILD_OS=alpine:3.19
33
ARG OPENSSL_VERSION=3.0.9
44

5+
FROM ${BUILD_OS} as alpine
6+
ARG OPENSSL_VERSION
7+
58
RUN apk add --no-cache --virtual .build-deps \
69
make gcc libgcc musl-dev linux-headers perl vim \
710
&& wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz \

0 commit comments

Comments
 (0)