Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dazz committed Aug 2, 2024
1 parent 482972a commit f2b18c6
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 7 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/docker-image-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Docker Image CI

on:
workflow_dispatch:
schedule:
- cron: '4 20 * * 4'
push:
branches: [ main ]

jobs:
latest_version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.fetch_tag.outputs.tag }}
steps:
- name: Fetch latest version
id: fetch_tag
run: |
API_TOKEN="${{ secrets.GITHUB_TOKEN }}"
REPO_OWNER="just-containers"
REPO_NAME="s6-overlay"
curl -sH "Authorization: token $API_TOKEN" https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest > latest_version.json
tag_name=$(jq -r '.tag_name' latest_version.json)
echo "::set-output name=tag::$tag_name"
check_image_tag:
runs-on: ubuntu-latest
needs: latest_version
outputs:
image_exists: ${{ steps.check_image.outputs.exists }}
steps:
- name: Check image tag exists
id: check_image
run: |
IMAGE_NAME="hakindazz/s6-overlay-base"
IMAGE_TAG=${{ needs.latest_version.outputs.tag }}
docker pull "$IMAGE_NAME:$IMAGE_TAG" &> /dev/null
if [ $? -eq 0 ]; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
build-and-push:
runs-on: ubuntu-latest
needs: [latest_version, check_image_tag]
if: "!needs.check_image_tag.outputs.image_exists"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: |
hakindazz/s6-overlay-base:latest
hakindazz/s6-overlay-base:${{ needs.latest_version.outputs.tag }}
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
FROM alpine:3

ENV S6_PATH=/s6/root
FROM alpine:3 AS s6

ARG TARGETARCH
ARG TARGETVARIANT
Expand All @@ -25,4 +23,7 @@ RUN apk add --no-cache curl jq \
&& sha256sum -c s6-overlay-${S6_PLATFORM}.tar.xz.sha256 \
&& mkdir -p /s6/root \
&& tar -C /s6/root -Jxpf /tmp/s6-overlay-noarch.tar.xz \
&& tar -C /s6/root -Jxpf /tmp/s6-overlay-${S6_PLATFORM}.tar.xz
&& tar -C /s6/root -Jxpf /tmp/s6-overlay-${S6_PLATFORM}.tar.xz

FROM scratch
COPY --from=s6 /s6/root /s6/root
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

.PHONY: build
build:
docker build --no-cache --build-arg S6_RELEASE=3.2.0.0 -t hakindazz/s6-overlay:3.2.0.0 .
docker build --no-cache --build-arg S6_RELEASE=3.2.0.0 -t hakindazz/s6-overlay-base:3.2.0.0 .

.PHONY: push
push:
docker push hakindazz/s6-overlay-base:3.2.0.0
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# s6-overlay base image
This repo tries to fill a small gap by providing a s6-overlay base image.
This repo fills a small gap by providing a s6-overlay base image.

## Usage

```Dockerfile
FROM hakindazz/s6-overlay AS s6-overlay
FROM hakindazz/s6-overlay-base AS s6-overlay
FROM alpine3

COPY --from=s6-overlay /s6/root /
Expand Down

0 comments on commit f2b18c6

Please sign in to comment.