Skip to content

Commit 48d8294

Browse files
authored
Build local-volume-provider image with chainguard (#37)
* Build local-volume-provider image with chainguard
1 parent 7ef8409 commit 48d8294

File tree

7 files changed

+121
-21
lines changed

7 files changed

+121
-21
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Build and push local-volume-provider image'
2+
description: 'Composite action for building and pushing local-volume-provider image'
3+
inputs:
4+
image-name:
5+
description: 'Full destination local-volume-provider image name'
6+
required: true
7+
8+
git-tag:
9+
description: 'Git tag'
10+
required: true
11+
12+
registry-username:
13+
description: 'Username to login to registry'
14+
default: ''
15+
required: false
16+
17+
registry-password:
18+
description: 'Password to login to registry'
19+
default: ''
20+
required: false
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
- name: template melange and apko configs
26+
shell: bash
27+
run: |
28+
export GIT_TAG=${{ inputs.git-tag }}
29+
envsubst '${GIT_TAG}' < deploy/melange.yaml.tmpl > deploy/melange.yaml
30+
envsubst '${GIT_TAG}' < deploy/apko.yaml.tmpl > deploy/apko.yaml
31+
32+
- id: cache-dir
33+
shell: bash
34+
run: echo "cache_dir=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
35+
36+
- uses: chainguard-dev/actions/melange-build@main
37+
with:
38+
config: deploy/melange.yaml
39+
archs: x86_64
40+
sign-with-temporary-key: true
41+
cache-dir: ${{ steps.cache-dir.outputs.cache_dir }}
42+
43+
- uses: chainguard-images/actions/apko-publish@main
44+
with:
45+
config: deploy/apko.yaml
46+
archs: x86_64
47+
tag: ${{ inputs.image-name }}
48+
vcs-url: true
49+
generic-user: ${{ inputs.registry-username }}
50+
generic-pass: ${{ inputs.registry-password }}

.github/workflows/daily-scan.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ jobs:
3636
- name: Checkout
3737
uses: actions/checkout@v3
3838

39-
- name: Build local-volume-provider image from Dockerfile
40-
run: |
41-
docker build --pull -t replicated/local-volume-provider:${{ github.sha }} -f deploy/local-volume-provider/Dockerfile --build-arg VERSION=${{ github.sha }} .
42-
39+
- uses: ./.github/actions/build-push-lvp-image
40+
with:
41+
image-name: ttl.sh/automated-${{ github.run_id }}/local-volume-provider:${{ github.sha }}
42+
git-tag: ${{ github.sha }}
43+
4344
- name: Run Trivy vulnerability scanner
4445
uses: aquasecurity/trivy-action@master
4546
with:
46-
image-ref: 'replicated/local-volume-provider:${{ github.sha }}'
47+
image-ref: 'ttl.sh/automated-${{ github.run_id }}/local-volume-provider:${{ github.sha }}'
4748
format: 'sarif'
4849
output: 'trivy-results.sarif'
4950
ignore-unfixed: true

.github/workflows/deploy.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,9 @@ jobs:
1515
id: get_tag
1616
shell: bash
1717
run: echo ::set-output name=GIT_TAG::${GITHUB_REF/refs\/tags\//}
18-
- uses: azure/docker-login@v1
19-
env:
20-
DOCKER_CONFIG: ./.docker
18+
- uses: ./.github/actions/build-push-lvp-image
2119
with:
22-
username: ${{ secrets.DOCKERHUB_USER }}
23-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
24-
- name: Build
25-
env:
26-
VERSION: ${{ steps.get_tag.outputs.GIT_TAG }}
27-
DOCKER_CONFIG: ./.docker
28-
run: |
29-
make container
30-
make push
20+
image-name: index.docker.io/replicated/local-volume-provider:${{ steps.get_tag.outputs.GIT_TAG }}
21+
git-tag: ${{ steps.get_tag.outputs.GIT_TAG }}
22+
registry-username: ${{ secrets.DOCKERHUB_USER }}
23+
registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
REGISTRY ?= replicated
33

44
PLUGIN_NAME ?= local-volume-provider
5-
PLUGIN_IMAGE ?= $(REGISTRY)/$(PLUGIN_NAME)
5+
PLUGIN_IMAGE ?= $(REGISTRY)/$(PLUGIN_NAME)
66

7-
VERSION ?= main
7+
VERSION ?= main
88
CURRENT_USER := $(shell id -u -n)
99

1010
GOOS ?= $(shell go env GOOS)
@@ -32,7 +32,7 @@ ci: verify-modules local test
3232

3333
.PHONY: container
3434
container:
35-
docker build --pull -t $(PLUGIN_IMAGE):$(VERSION) -f deploy/local-volume-provider/Dockerfile --build-arg VERSION=$(VERSION) .
35+
docker build --pull -t $(PLUGIN_IMAGE):$(VERSION) -f deploy/Dockerfile --build-arg VERSION=$(VERSION) .
3636

3737
# push pushes the Docker image to its registry.
3838
.PHONY: push
@@ -45,7 +45,7 @@ endif
4545

4646
.PHONY ttl.sh:
4747
ttl.sh:
48-
docker build -t $(CURRENT_USER)/$(PLUGIN_NAME):12h -f deploy/local-volume-provider/Dockerfile .
48+
docker build -t $(CURRENT_USER)/$(PLUGIN_NAME):12h -f deploy/Dockerfile .
4949
docker tag $(CURRENT_USER)/$(PLUGIN_NAME):12h ttl.sh/$(CURRENT_USER)/$(PLUGIN_NAME):12h
5050
@docker push ttl.sh/$(CURRENT_USER)/$(PLUGIN_NAME):12h
5151

File renamed without changes.

deploy/apko.yaml.tmpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
contents:
2+
repositories:
3+
- https://packages.wolfi.dev/os
4+
- ./packages/
5+
keyring:
6+
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
7+
- ./melange.rsa.pub
8+
packages:
9+
- local-volume-provider-head # This is expected to be built locally by `melange`.
10+
- bash
11+
- busybox
12+
- curl
13+
- git
14+
- wolfi-baselayout
15+
16+
environment:
17+
VERSION: ${GIT_TAG}
18+
19+
cmd: /bin/bash -c "cp /plugins/* /target/."

deploy/melange.yaml.tmpl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package:
2+
name: local-volume-provider-head
3+
version: ${GIT_TAG}
4+
epoch: 0
5+
description: local-volume-provider package
6+
copyright:
7+
- license: Apache-2.0
8+
9+
environment:
10+
contents:
11+
repositories:
12+
- https://packages.wolfi.dev/os
13+
keyring:
14+
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
15+
packages:
16+
- ca-certificates-bundle
17+
- busybox
18+
- git
19+
- go
20+
environment:
21+
GOMODCACHE: '/var/cache/melange'
22+
23+
pipeline:
24+
- runs: |
25+
set -x
26+
export DESTDIR="${{targets.destdir}}"
27+
mkdir -p "${DESTDIR}/plugins"
28+
29+
export VERSION=${{package.version}}
30+
31+
CGO_ENABLED=0 go build \
32+
-ldflags=" -X github.com/replicatedhq/local-volume-provider/pkg/version.version=$VERSION " \
33+
-o "${DESTDIR}/plugins/local-volume-provider" ./cmd/local-volume-provider
34+
35+
CGO_ENABLED=0 go build \
36+
-ldflags=" -X github.com/replicatedhq/local-volume-provider/pkg/version.version=$VERSION " \
37+
-o "${DESTDIR}/local-volume-fileserver" ./cmd/local-volume-fileserver

0 commit comments

Comments
 (0)