Refactor action workflows and dockerfile
Build and push Alpine Linux container images / Get build meta (push) Successful in 6s Details
Build and push Alpine Linux container images / Build alpine linux container images (push) Failing after 26s Details

This commit is contained in:
Muhamad Aditya Prima 2024-12-15 16:33:02 +07:00
parent e7c4835c08
commit 8943f39f02
5 changed files with 124 additions and 336 deletions

View File

@ -0,0 +1,76 @@
name: Build and push Alpine Linux container images
on:
push:
branches:
- master
jobs:
prepare:
name: Get build meta
runs-on: ubuntu-latest
container:
image: ghcr.io/catthehacker/ubuntu:act-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Get build-meta.json content
id: get-build-meta
uses: ActionsTools/read-json-action@main
with:
file_path: "build-meta.json"
outputs:
versions: ${{ steps.get-build-meta.outputs.versions }}
build:
name: Build alpine linux container images
container:
image: ghcr.io/catthehacker/ubuntu:act-latest
runs-on: ubuntu-latest
needs:
- prepare
strategy:
matrix:
version: ${{ fromJson(needs.prepare.outputs.versions) }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Login to docker.io
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and push alpine ${{ matrix.version }}
uses: docker/build-push-action@v5
with:
# platforms: linux/amd64,linux/arm64
push: true
context: .
build-args: |
ALPINE_VERSION=${{ matrix.version }}
tags: |
${{ vars.DOCKERHUB_USERNAME }}/alpine:${{ matrix.version }}
- name: Build latest version
uses: docker/build-push-action@v5
with:
# platforms: linux/amd64,linux/arm64
push: true
context: .
tags: |
${{ vars.DOCKERHUB_USERNAME }}/alpine:latest
# - name: Scan alpine9 image with Trivy
# uses: aquasecurity/trivy-action@0.20.0
# with:
# image-ref: '${{ vars.DOCKERHUB_USERNAME }}/alpine:9.5'
# format: 'sarif'
# output: 'trivy-results.sarif'
# - name: Scan alpine9-micro image with Trivy
# uses: aquasecurity/trivy-action@0.20.0
# with:
# image-ref: '${{ vars.DOCKERHUB_USERNAME }}/alpine:9.5-micro'
# format: 'sarif'
# output: 'trivy-results.sarif'

View File

@ -1,163 +0,0 @@
name: Build and Push Alpine Image
on:
push:
branches:
- master
jobs:
build:
name: Build and push image
runs-on: ubuntu-latest
container:
image: ghcr.io/catthehacker/ubuntu:act-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: docker.io
username: aprimediet
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push 3.5
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.5
push: true
tags: |
aprimediet/alpine:3.5
- name: Build and push 3.9
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.9
push: true
tags: |
aprimediet/alpine:3.9
- name: Build and push 3.10
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.10
push: true
tags: |
aprimediet/alpine:3.10
- name: Build and push 3.11
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.11
push: true
tags: |
aprimediet/alpine:3.11
- name: Build and push 3.12
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.12
push: true
tags: |
aprimediet/alpine:3.12
- name: Build and push 3.13
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.13
push: true
tags: |
aprimediet/alpine:3.13
- name: Build and push 3.14
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.14
push: true
tags: |
aprimediet/alpine:3.14
- name: Build and push 3.15
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.15
push: true
tags: |
aprimediet/alpine:3.15
- name: Build and push 3.16
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.16
push: true
tags: |
aprimediet/alpine:3.16
- name: Build and push 3.17
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.17
push: true
tags: |
aprimediet/alpine:3.17
- name: Build and push 3.18
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.18
push: true
tags: |
aprimediet/alpine:3.18
- name: Build and push 3.19
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.19
push: true
tags: |
aprimediet/alpine:3.19
- name: Build and push 3.20
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.20
push: true
tags: |
aprimediet/alpine:3.20
- name: Build and push 3.21
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.21
push: true
tags: |
aprimediet/alpine:3.21
aprimediet/alpine:3
aprimediet/alpine:latest

View File

@ -1,163 +0,0 @@
name: Build and Push Alpine Image to Winter Access Registry
on:
push:
branches:
- master
jobs:
build:
name: Build and push image
runs-on: ubuntu-latest
container:
image: ghcr.io/catthehacker/ubuntu:act-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: git.winteraccess.id
username: ${{ vars.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push 3.5
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.5
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.5
- name: Build and push 3.9
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.9
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.9
- name: Build and push 3.10
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.10
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.10
- name: Build and push 3.11
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.11
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.11
- name: Build and push 3.12
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.12
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.12
- name: Build and push 3.13
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.13
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.13
- name: Build and push 3.14
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.14
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.14
- name: Build and push 3.15
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.15
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.15
- name: Build and push 3.16
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.16
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.16
- name: Build and push 3.17
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.17
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.17
- name: Build and push 3.18
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.18
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.18
- name: Build and push 3.19
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.19
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.19
- name: Build and push 3.20
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.20
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.20
- name: Build and push 3.21
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: |
ALPINE_VERSION=3.21
push: true
tags: |
git.winteraccess.id/${{ gitea.repository }}:3.21
git.winteraccess.id/${{ gitea.repository }}:3
git.winteraccess.id/${{ gitea.repository }}:latest

View File

@ -1,21 +1,39 @@
ARG ALPINE_VERSION=3.21
FROM alpine:${ALPINE_VERSION}
LABEL maintainer="<Aditya Prima> aprimediet@gmail.com"
FROM alpine:${ALPINE_VERSION} AS builder
ARG ALPINE_VERSION=3.20
ARG ALPINE_VERSION=3.21
ARG TZ=Asia/Jakarta
# Set User as root
USER root
# INSTALL BASE DEPENDENCIES
# Install base dependencies, set timezone to designated timezone
RUN --mount=type=cache,target=/var/cache/apk \
apk add --update \
libcap tzdata curl
/sbin/apk update --no-cache; \
/sbin/apk upgrade --no-cache; \
/sbin/apk add --update --no-cache \
tzdata; \
/bin/echo $TZ > /etc/timezone; \
/bin/cp /usr/share/zoneinfo/$TZ /etc/localtime; \
/sbin/apk del --no-cache tzdata; \
/bin/rm -vrf /var/cache/apk/*;
# SET LOCAL TIMEZONE
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
FROM scratch
# CLEAN APK CACHES
RUN rm -vrf /var/cache/apk/*
ARG ALPINE_VERSION=3.21
LABEL maintainer="Muhamad Aditya Prima <aprimediet@gmail.com>"
LABEL name="alpine"
LABEL version="${ALPINE_VERSION}"
LABEL distribution-scope="public"
#labels for container catalog
LABEL summary="Alpine Linux ${ALPINE_VERSION} container image"
LABEL description="Provide latest release of Alpine Linux ${ALPINE_VERSION} container base image"
LABEL io.k8s.description="Very small alpine linux container image"
LABEL io.k8s.display-name="Alpine Linux ${ALPINE_VERSION}"
COPY --from=builder / /
CMD ["/bin/sh"]

20
build-meta.json Normal file
View File

@ -0,0 +1,20 @@
{
"versions": [
"3.6",
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
"3.14",
"3.15",
"3.16",
"3.17",
"3.18",
"3.19",
"3.20",
"3.21"
]
}