This commit is contained in:
1 parent
8b7d5bd534
commit
73918eeff3
1 file changed
+32
-18
@@ -1,13 +1,10 @@
|
||||
name: Prueba de construcción de imagen
|
||||
name: Construir y publicar imagen de prueba
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- .gitea/workflows/prueba-imagen.yml
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
construir:
|
||||
publicar:
|
||||
runs-on: gitea-ci
|
||||
timeout-minutes: 15
|
||||
|
||||
@@ -20,35 +17,52 @@ jobs:
|
||||
--security-opt systempaths=unconfined
|
||||
|
||||
steps:
|
||||
- name: Construir y exportar imagen
|
||||
- name: Construir y publicar en Gitea
|
||||
shell: sh
|
||||
working-directory: /tmp
|
||||
env:
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
BUILDKITD_FLAGS: >-
|
||||
--oci-worker-snapshotter=native
|
||||
--oci-worker-no-process-sandbox
|
||||
run: |
|
||||
set -eu
|
||||
umask 077
|
||||
|
||||
CONTEXT=$(mktemp -d /tmp/prueba-build.XXXXXX)
|
||||
trap 'rm -rf "$CONTEXT"' EXIT
|
||||
: "${REGISTRY_USER:?Falta REGISTRY_USER}"
|
||||
: "${REGISTRY_TOKEN:?Falta REGISTRY_TOKEN}"
|
||||
: "${COMMIT_SHA:?Falta COMMIT_SHA}"
|
||||
|
||||
cat > "$CONTEXT/Dockerfile" <<'EOF'
|
||||
WORK=$(mktemp -d /tmp/prueba-registry.XXXXXX)
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
mkdir "$WORK/context" "$WORK/auth"
|
||||
export DOCKER_CONFIG="$WORK/auth"
|
||||
|
||||
AUTH=$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" |
|
||||
base64 | tr -d '\n')
|
||||
|
||||
printf '{"auths":{"git.becodes.com.ar":{"auth":"%s"}}}\n' \
|
||||
"$AUTH" > "$DOCKER_CONFIG/config.json"
|
||||
|
||||
unset AUTH REGISTRY_TOKEN REGISTRY_USER
|
||||
|
||||
cat > "$WORK/context/Dockerfile" <<'EOF'
|
||||
FROM alpine:3.23
|
||||
RUN printf 'Imagen construida desde Gitea Actions\n' > /prueba.txt \
|
||||
RUN printf 'Imagen publicada desde Gitea Actions\n' > /prueba.txt \
|
||||
&& test -s /prueba.txt
|
||||
CMD ["cat", "/prueba.txt"]
|
||||
EOF
|
||||
|
||||
IMAGE="git.becodes.com.ar/becodes-team/prueba-infra:ci-${COMMIT_SHA}"
|
||||
|
||||
buildctl-daemonless.sh build \
|
||||
--frontend dockerfile.v0 \
|
||||
--local context="$CONTEXT" \
|
||||
--local dockerfile="$CONTEXT" \
|
||||
--local context="$WORK/context" \
|
||||
--local dockerfile="$WORK/context" \
|
||||
--opt platform=linux/amd64 \
|
||||
--output "type=oci,dest=$CONTEXT/imagen.tar"
|
||||
--output "type=image,name=$IMAGE,push=true"
|
||||
|
||||
test -s "$CONTEXT/imagen.tar"
|
||||
tar -tf "$CONTEXT/imagen.tar"
|
||||
sha256sum "$CONTEXT/imagen.tar"
|
||||
|
||||
echo "Imagen construida y exportada correctamente"
|
||||
echo "Imagen publicada: $IMAGE"
|
||||
Reference in new issue
Block a user