feat: minimize container size and caching

This commit is contained in:
npub15skvhry
2026-05-15 12:53:15 +03:30
parent ab21008f34
commit e9d17c7264
8 changed files with 192 additions and 77 deletions
+95
View File
@@ -0,0 +1,95 @@
name: Container Build and Publish
on:
push:
branches: [ master ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: gitea.coracle.social
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set Variables
id: set_variables
run: |
# convert everything to lowercase because ghcr repository name must be lowercase
ACTOR="${GITHUB_ACTOR,,}"
REPOSITORY="${GITHUB_REPOSITORY##*/}"
REPOSITORY="${REPOSITORY,,}"
echo "actor=${ACTOR}" >> $GITHUB_OUTPUT
echo "repository=${REPOSITORY}" >> $GITHUB_OUTPUT
shell: bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PACKAGE_TOKEN }}
- name: Extract metadata (tags, labels) for nodejs image
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.set_variables.outputs.actor }}/${{ steps.set_variables.outputs.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
- name: Build and push nodejs-based image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: ./Containerfile
push: true
target: production-nodejs
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
#cache-from: type=gha
#cache-to: type=gha,mode=max
#- name: Extract metadata (tags, labels) for nginx image
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: ${{ env.REGISTRY }}/${{ steps.set_variables.outputs.actor }}/${{ steps.set_variables.outputs.repository }}-nginx
# tags: |
# type=ref,event=branch
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
# type=sha,prefix={{branch}}-
# type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
#- name: Build and push nginx-based image
# id: push
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./Containerfile
# push: true
# target: production-nginx
# platforms: linux/amd64,linux/arm64
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
-50
View File
@@ -1,50 +0,0 @@
name: Docker
on:
push:
branches: [master]
env:
REGISTRY: gitea.coracle.social
IMAGE_NAME: coracle/flotilla
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: hodlbod
password: ${{ secrets.PACKAGE_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}