modified: .gitea/limbo_actions/buildkit-build-push/action.yaml
/ build-docker-image (push) Successful in 14s
/ build-docker-image (push) Successful in 14s
new file: .gitea/limbo_actions/buildkit-build-push_v2/action.yaml
This commit is contained in:
@@ -38,16 +38,27 @@ runs:
|
||||
- name: run buildctl build and push
|
||||
shell: bash
|
||||
run: |
|
||||
cat > /tmp/registry-config.json <<EOF
|
||||
# create docker config temp folder
|
||||
DOCKER_CONFIG_DIR="${RUNNER_TEMP}/.buildctl_docker"
|
||||
mkdir -p "$DOCKER_CONFIG_DIR"
|
||||
|
||||
# clean up
|
||||
trap 'rm -rf "$DOCKER_CONFIG_DIR"' EXIT
|
||||
|
||||
|
||||
# setup file docker config (auth) temp file
|
||||
AUTH=$(printf "%s" "${{ inputs.registry_username }}:${{ inputs.registry_password }}" | base64 -w 0)
|
||||
cat > "$DOCKER_CONFIG_DIR/config.json" <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"oci.limbosolutions.com": {
|
||||
"auth": "$(printf '%s:%s' "${{ inputs.registry_username }}" "${{ inputs.registry_password }}" | base64 -w0)"
|
||||
"${{ inputs.registry_addr }}": {
|
||||
"auth": "$AUTH"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
# Build build-arg flags
|
||||
BUILD_ARG_FLAGS=""
|
||||
while IFS= read -r line; do
|
||||
@@ -57,14 +68,13 @@ runs:
|
||||
|
||||
echo "Using build args: $BUILD_ARG_FLAGS"
|
||||
|
||||
# Build + push com credenciais por build
|
||||
buildctl \
|
||||
# Run BuildKit build
|
||||
DOCKER_CONFIG=$DOCKER_CONFIG_DIR buildctl \
|
||||
--addr ${{ inputs.buildkit_addr }} \
|
||||
build \
|
||||
--registry-config /tmp/registry-config.json \
|
||||
--frontend=dockerfile.v0 \
|
||||
--local context=${{ inputs.context }} \
|
||||
--local dockerfile=${{ inputs.dockerfile }} \
|
||||
--opt filename=${{ inputs.filename }} \
|
||||
$BUILD_ARG_FLAGS \
|
||||
--output type=image,name=${{ inputs.tags }},push=true
|
||||
--output type=image,name=${{ inputs.tags }},push=true
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
name: BuildKit Build and push
|
||||
description: "Build and push images using remote Buildkit"
|
||||
inputs:
|
||||
registry_addr:
|
||||
description: registry address
|
||||
required: true
|
||||
registry_username:
|
||||
description: "registry username"
|
||||
required: true
|
||||
registry_password:
|
||||
description: "registry password"
|
||||
required: true
|
||||
buildkit_addr:
|
||||
description: "buildkit address"
|
||||
required: true
|
||||
tags:
|
||||
description: "image tags / buildctl image name"
|
||||
required: true
|
||||
context:
|
||||
description: "buildctl build context"
|
||||
required: false
|
||||
default: "."
|
||||
dockerfile:
|
||||
description: "buildctl build dockerfile/folder"
|
||||
required: true
|
||||
default: "."
|
||||
filename:
|
||||
description: "Docker file name (Default: Dockerfile)"
|
||||
required: true
|
||||
default: "Dockerfile"
|
||||
build_args:
|
||||
description: "Build arguments (multiline KEY=VALUE)"
|
||||
required: false
|
||||
default: ""
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: run buildctl build and push
|
||||
shell: bash
|
||||
run: |
|
||||
# create docker config temp folder
|
||||
DOCKER_CONFIG_DIR="${RUNNER_TEMP}/.buildctl_docker"
|
||||
mkdir -p "$DOCKER_CONFIG_DIR"
|
||||
|
||||
# clean up
|
||||
trap 'rm -rf "$DOCKER_CONFIG_DIR"' EXIT
|
||||
|
||||
# setup file docker config (auth) temp file
|
||||
AUTH=$(printf "%s" "${{ inputs.registry_username }}:${{ inputs.registry_password }}" | base64 -w 0)
|
||||
|
||||
cat > "$DOCKER_CONFIG_DIR/config.json" <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"${{ inputs.registry_addr }}": {
|
||||
"auth": "$AUTH"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
###############################################
|
||||
# BuildKit ROOTLESS LOCAL
|
||||
###############################################
|
||||
|
||||
# Criar diretórios rootless
|
||||
export XDG_RUNTIME_DIR=/tmp/run
|
||||
mkdir -p "$XDG_RUNTIME_DIR/buildkit"
|
||||
|
||||
# Arrancar buildkitd rootless (em background)
|
||||
rootlesskit \
|
||||
--net=slirp4netns \
|
||||
--disable-host-loopback \
|
||||
buildkitd \
|
||||
--addr unix://$XDG_RUNTIME_DIR/buildkit/buildkitd.sock \
|
||||
--oci-worker-no-process-sandbox \
|
||||
--rootless \
|
||||
--debug &
|
||||
|
||||
# Esperar o socket
|
||||
sleep 3
|
||||
|
||||
###############################################
|
||||
# Build args
|
||||
###############################################
|
||||
|
||||
BUILD_ARG_FLAGS=""
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
BUILD_ARG_FLAGS="$BUILD_ARG_FLAGS --opt build-arg:${line}"
|
||||
done <<< "${{ inputs.build_args }}"
|
||||
|
||||
echo "Using build args: $BUILD_ARG_FLAGS"
|
||||
|
||||
###############################################
|
||||
# Build + push + cache
|
||||
###############################################
|
||||
# --import-cache type=registry,ref=oci.limbosolutions.com/cache/project:latest \
|
||||
# --export-cache type=registry,ref=oci.limbosolutions.com/cache/project:latest,mode=max \
|
||||
|
||||
DOCKER_CONFIG=$DOCKER_CONFIG_DIR buildctl \
|
||||
--addr unix://$XDG_RUNTIME_DIR/buildkit/buildkitd.sock \
|
||||
build \
|
||||
--frontend=dockerfile.v0 \
|
||||
--local context=${{ inputs.context }} \
|
||||
--local dockerfile=${{ inputs.dockerfile }} \
|
||||
--opt filename=${{ inputs.filename }} \
|
||||
$BUILD_ARG_FLAGS \
|
||||
--output type=image,name=${{ inputs.tags }},push=true
|
||||
Reference in New Issue
Block a user