fix(ci): use crane for HTTP registry push (replaces buildx)
This commit is contained in:
@@ -121,62 +121,40 @@ jobs:
|
|||||||
git clone --depth=1 --branch=${GITHUB_REF_NAME} ${REPO_URL}/${GITHUB_REPOSITORY}.git .
|
git clone --depth=1 --branch=${GITHUB_REF_NAME} ${REPO_URL}/${GITHUB_REPOSITORY}.git .
|
||||||
git checkout ${GITHUB_SHA}
|
git checkout ${GITHUB_SHA}
|
||||||
|
|
||||||
- name: Setup Docker Buildx for insecure registry
|
- name: Install crane and build images
|
||||||
run: |
|
run: |
|
||||||
REGISTRY_URL=$(echo ${GITHUB_SERVER_URL} | sed 's|.*://||')
|
# Install crane for pushing to insecure HTTP registry
|
||||||
|
curl -sL https://github.com/google/go-containerregistry/releases/download/v0.19.0/go-containerregistry_Linux_x86_64.tar.gz | tar xz crane
|
||||||
|
chmod +x crane
|
||||||
|
|
||||||
# Create buildkitd config for HTTP registry
|
|
||||||
cat > /tmp/buildkitd.toml << EOF
|
|
||||||
[registry."${REGISTRY_URL}"]
|
|
||||||
http = true
|
|
||||||
insecure = true
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create docker config.json with credentials (for buildx)
|
|
||||||
mkdir -p ~/.docker
|
|
||||||
AUTH=$(echo -n "${{ gitea.actor }}:${{ gitea.token }}" | base64 -w 0)
|
|
||||||
cat > ~/.docker/config.json << EOF
|
|
||||||
{
|
|
||||||
"auths": {
|
|
||||||
"${REGISTRY_URL}": {
|
|
||||||
"auth": "${AUTH}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create buildx builder with insecure registry and mount docker config
|
|
||||||
docker buildx create --name insecure-builder \
|
|
||||||
--driver docker-container \
|
|
||||||
--config /tmp/buildkitd.toml \
|
|
||||||
--driver-opt network=host \
|
|
||||||
--use
|
|
||||||
docker buildx inspect --bootstrap
|
|
||||||
|
|
||||||
- name: Build and push images
|
|
||||||
run: |
|
|
||||||
BRANCH_TAG=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')
|
BRANCH_TAG=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')
|
||||||
SHA_SHORT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
SHA_SHORT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
||||||
REGISTRY_URL=$(echo ${GITHUB_SERVER_URL} | sed 's|.*://||')
|
REGISTRY_URL=$(echo ${GITHUB_SERVER_URL} | sed 's|.*://||')
|
||||||
REGISTRY="${REGISTRY_URL}/${{ github.repository_owner }}"
|
REGISTRY="${REGISTRY_URL}/${{ github.repository_owner }}"
|
||||||
|
|
||||||
# Build and push web image
|
# Build web image locally
|
||||||
docker buildx build --push \
|
docker build -f ./docker/Dockerfile.web -t mostovik-web:local .
|
||||||
-f ./docker/Dockerfile.web \
|
docker save mostovik-web:local -o /tmp/web.tar
|
||||||
-t ${REGISTRY}/mostovik-web:${BRANCH_TAG} \
|
|
||||||
-t ${REGISTRY}/mostovik-web:${BRANCH_TAG}-${SHA_SHORT} \
|
|
||||||
$([ "${GITHUB_REF_NAME}" = "main" ] && echo "-t ${REGISTRY}/mostovik-web:latest") \
|
|
||||||
.
|
|
||||||
|
|
||||||
# Build and push celery image
|
# Push with crane (supports insecure HTTP)
|
||||||
docker buildx build --push \
|
./crane auth login ${REGISTRY_URL} -u ${{ gitea.actor }} -p ${{ gitea.token }}
|
||||||
-f ./docker/Dockerfile.celery \
|
./crane push --insecure /tmp/web.tar ${REGISTRY}/mostovik-web:${BRANCH_TAG}
|
||||||
-t ${REGISTRY}/mostovik-celery:${BRANCH_TAG} \
|
./crane push --insecure /tmp/web.tar ${REGISTRY}/mostovik-web:${BRANCH_TAG}-${SHA_SHORT}
|
||||||
-t ${REGISTRY}/mostovik-celery:${BRANCH_TAG}-${SHA_SHORT} \
|
|
||||||
$([ "${GITHUB_REF_NAME}" = "main" ] && echo "-t ${REGISTRY}/mostovik-celery:latest") \
|
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||||
.
|
./crane push --insecure /tmp/web.tar ${REGISTRY}/mostovik-web:latest
|
||||||
env:
|
fi
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
|
# Build celery image locally
|
||||||
|
docker build -f ./docker/Dockerfile.celery -t mostovik-celery:local .
|
||||||
|
docker save mostovik-celery:local -o /tmp/celery.tar
|
||||||
|
|
||||||
|
./crane push --insecure /tmp/celery.tar ${REGISTRY}/mostovik-celery:${BRANCH_TAG}
|
||||||
|
./crane push --insecure /tmp/celery.tar ${REGISTRY}/mostovik-celery:${BRANCH_TAG}-${SHA_SHORT}
|
||||||
|
|
||||||
|
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||||
|
./crane push --insecure /tmp/celery.tar ${REGISTRY}/mostovik-celery:latest
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Image summary
|
- name: Image summary
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user