2023-07-04 11:46:49 +00:00
|
|
|
name: Docker
|
|
|
|
|
2023-03-08 11:45:55 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2023-07-04 11:46:49 +00:00
|
|
|
- master
|
2023-03-08 11:45:55 +00:00
|
|
|
tags:
|
|
|
|
- "v*.*.*"
|
2023-07-04 11:46:49 +00:00
|
|
|
paths-ignore:
|
|
|
|
- '**/*.md'
|
|
|
|
- '.gitignore'
|
|
|
|
- '.github/**'
|
|
|
|
- '!.github/workflows/docker.yml'
|
|
|
|
- 'docker/**'
|
|
|
|
- '!docker/codex.Dockerfile'
|
|
|
|
- '!docker/docker-entrypoint.sh'
|
2023-04-18 12:17:24 +00:00
|
|
|
workflow_dispatch:
|
2023-03-08 11:45:55 +00:00
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
DOCKER_FILE: docker/codex.Dockerfile
|
|
|
|
DOCKER_REPO: codexstorage/nim-codex
|
|
|
|
MAKE_PARALLEL: 4
|
|
|
|
|
|
|
|
|
2023-03-08 11:45:55 +00:00
|
|
|
jobs:
|
2023-07-04 11:46:49 +00:00
|
|
|
# Build platform specific image
|
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- os: linux
|
|
|
|
arch: amd64
|
|
|
|
- os: linux
|
|
|
|
arch: arm64
|
|
|
|
include:
|
|
|
|
- target:
|
|
|
|
os: linux
|
|
|
|
arch: amd64
|
|
|
|
builder: ubuntu-22.04
|
|
|
|
- target:
|
|
|
|
os: linux
|
|
|
|
arch: arm64
|
|
|
|
builder: buildjet-4vcpu-ubuntu-2204-arm
|
|
|
|
|
|
|
|
name: Build ${{ matrix.target.os }}/${{ matrix.target.arch }}
|
|
|
|
runs-on: ${{ matrix.builder }}
|
|
|
|
outputs:
|
|
|
|
tags-linux-amd64: ${{ steps.tags.outputs.tags-linux-amd64 }}
|
|
|
|
tags-linux-arm64: ${{ steps.tags.outputs.tags-linux-arm64 }}
|
|
|
|
env:
|
|
|
|
PLATFORM: ${{ format('{0}/{1}', 'linux', matrix.target.arch) }}
|
|
|
|
SUFFIX: ${{ format('{0}-{1}', 'linux', matrix.target.arch) }}
|
2023-03-08 11:45:55 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
2023-06-19 06:28:27 +00:00
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Meta
|
2023-06-19 06:28:27 +00:00
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
2023-07-04 11:46:49 +00:00
|
|
|
images: ${{ env.DOCKER_REPO }}
|
|
|
|
flavor: |
|
|
|
|
latest=false
|
2023-06-19 06:28:27 +00:00
|
|
|
tags: |
|
2023-07-04 11:46:49 +00:00
|
|
|
type=semver,pattern={{version}},suffix=-${{ env.SUFFIX }}
|
|
|
|
type=sha,suffix=-${{ env.SUFFIX }},enable=${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
|
|
|
|
- name: Docker - Set tags output
|
|
|
|
id: tags
|
|
|
|
run: |
|
|
|
|
if [[ '${{ matrix.target.os }}' == 'linux' && '${{ matrix.target.arch }}' == 'amd64' ]]; then
|
|
|
|
echo "tags-linux-amd64=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
|
|
|
|
elif [[ '${{ matrix.target.os }}' == 'linux' && '${{ matrix.target.arch }}' == 'arm64' ]]; then
|
|
|
|
echo "tags-linux-arm64=${{ steps.meta.outputs.tags }}" >> "$GITHUB_OUTPUT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Docker - Login to Docker Hub
|
2023-06-19 06:28:27 +00:00
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Build and export to Docker
|
2023-06-19 06:28:27 +00:00
|
|
|
uses: docker/build-push-action@v4
|
|
|
|
with:
|
|
|
|
context: .
|
2023-07-04 11:46:49 +00:00
|
|
|
file: ${{ env.DOCKER_FILE }}
|
|
|
|
platforms: ${{ env.PLATFORM }}
|
|
|
|
build-args: |
|
|
|
|
MAKE_PARALLEL=${{ env.MAKE_PARALLEL }}
|
2023-06-19 06:28:27 +00:00
|
|
|
load: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Minify image
|
2023-06-19 06:28:27 +00:00
|
|
|
uses: kitabisa/docker-slim-action@v1
|
2023-07-04 11:46:49 +00:00
|
|
|
id: slim
|
2023-06-19 06:28:27 +00:00
|
|
|
env:
|
|
|
|
DSLIM_HTTP_PROBE: false
|
|
|
|
with:
|
|
|
|
target: ${{ steps.meta.outputs.tags }}
|
|
|
|
overwrite: true
|
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Show slim report
|
|
|
|
run: echo "${REPORT}" | jq -r
|
|
|
|
env:
|
|
|
|
REPORT: ${{ steps.slim.outputs.report }}
|
2023-06-19 06:28:27 +00:00
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Push to Docker registry
|
2023-06-19 06:28:27 +00:00
|
|
|
uses: docker/build-push-action@v4
|
|
|
|
with:
|
|
|
|
context: .
|
2023-07-04 11:46:49 +00:00
|
|
|
file: ${{ env.DOCKER_FILE }}
|
|
|
|
platforms: ${{ env.PLATFORM }}
|
2023-06-19 06:28:27 +00:00
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
# Publish single image
|
|
|
|
publish:
|
|
|
|
name: Push single image
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
2023-06-19 06:28:27 +00:00
|
|
|
steps:
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Meta
|
2023-03-08 11:45:55 +00:00
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
2023-07-04 11:46:49 +00:00
|
|
|
images: ${{ env.DOCKER_REPO }}
|
2023-03-08 11:45:55 +00:00
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
2023-07-04 11:46:49 +00:00
|
|
|
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
|
2023-06-19 06:28:27 +00:00
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Set tags
|
|
|
|
run: |
|
|
|
|
# Transform multi-line tags in to the comma-seperated
|
|
|
|
TAGS=$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ',' | awk '{gsub(/,$/,"");}1')
|
|
|
|
echo "TAGS=${TAGS}" >>$GITHUB_ENV
|
2023-06-19 06:28:27 +00:00
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Login to Docker Hub
|
2023-03-08 11:45:55 +00:00
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2023-06-19 06:28:27 +00:00
|
|
|
|
2023-07-04 11:46:49 +00:00
|
|
|
- name: Docker - Create and push manifest images
|
|
|
|
uses: Noelware/docker-manifest-action@master
|
2023-06-19 06:28:27 +00:00
|
|
|
with:
|
2023-07-04 11:46:49 +00:00
|
|
|
inputs: ${{ env.TAGS }}
|
|
|
|
images: ${{ needs.build.outputs.tags-linux-amd64 }},${{ needs.build.outputs.tags-linux-arm64 }}
|
2023-06-19 06:28:27 +00:00
|
|
|
push: true
|