-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Base for building subsequent images
- Loading branch information
1 parent
3666adb
commit 3f4eff4
Showing
3 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# cSpell: disable | ||
name: Build a box | ||
on: | ||
workflow_call: | ||
inputs: | ||
context: | ||
required: true | ||
type: string | ||
# secrets: | ||
# token: | ||
# required: true | ||
|
||
jobs: | ||
build-base: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
sha256sum: ${{ steps.compress.outputs.sha256sum }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
driver-opts: | | ||
image=moby/buildkit:master | ||
- name: Docker Login | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository }}-${{ inputs.context }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ${{ inputs.context }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Export as root fs | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ${{ inputs.context }} | ||
push: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
outputs: type=tar,dest=alpine-boxes-${{ inputs.context }}.rootfs.tar | ||
|
||
- name: Get distributions | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: shasums | ||
|
||
- name: Compress root filesystem and compute checksum | ||
id: compress | ||
env: | ||
BOX_NAME: ${{ inputs.context }} | ||
run: | | ||
gzip alpine-boxes-${BOX_NAME}.rootfs.tar | ||
sha256sum alpine-boxes-${BOX_NAME}.rootfs.tar.gz >> SHA256SUMS | ||
echo "sha256sum=$(tail -1 SHA256SUMS)" >>$GITHUB_OUTPUT | ||
- name: Upload root fs artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: rootfs | ||
path: | | ||
alpine-boxes-${{ inputs.context }}.rootfs.tar.gz | ||
- name: shasums artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: shasums | ||
path: | | ||
SHA256SUMS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ARG BASE_VERSION=latest | ||
|
||
FROM ghcr.io/kaweezle/alpine-boxes-base:${BASE_VERSION} | ||
|
||
USER root | ||
|
||
RUN apk add --no-cache docker && \ | ||
rc-update add docker default | ||
|
||
USER alpine |