Skip to content
Snippets Groups Projects
Verified Commit 1e74803f authored by David (Jointech)'s avatar David (Jointech)
Browse files

Revert "feat(ci): switch building to buildkit"

This reverts commit 03470ca4.
parent 03470ca4
No related branches found
No related tags found
No related merge requests found
Pipeline #2238 passed
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
- if: $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+$/ || $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+[-]\S+$/ - if: $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+$/ || $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+[-]\S+$/
exists: exists:
- Dockerfile - Dockerfile
variables:
IMAGE: $IMAGE_LATEST
stages: stages:
- test - test
...@@ -21,54 +19,34 @@ lint: ...@@ -21,54 +19,34 @@ lint:
- npm run lint -- --no-fix - npm run lint -- --no-fix
docker-push: docker-push:
# Use the official docker image.
image: docker:latest
stage: release stage: release
image:
name: moby/buildkit:v0.10.3-rootless
entrypoint: ["sh", "-c"]
variables: variables:
DOCKER_CONTEXT: .
DOCKERFILE_DIR: .
DOCKERFILE_NAME: "Dockerfile"
BUILDKIT_ARGS: ""
# the name of the image without version # the name of the image without version
AURA_IMAGE_NAME: "autoradio/dashboard" AURA_IMAGE_NAME: "autoradio/dashboard"
IMAGE: "name=$AURA_IMAGE_NAME:unstable" services:
IMAGE_LATEST: "name=$AURA_IMAGE_NAME:$CI_COMMIT_TAG,$AURA_IMAGE_NAME:latest" - docker:dind
BUILD_CACHE: "$CI_REGISTRY_IMAGE/buildcache" before_script:
# Necessary for buildkit in docker build # default repo is docker.io (aka docker hub)
BUILDKITD_FLAGS: "--oci-worker-no-process-sandbox" - docker login -u "$DOCKER_ID" -p "$DOCKER_HUB_AUTH"
# Also login and push to Docker hub script:
DOCKERHUB_USER: "$DOCKER_ID" # every commit on main branch should build image as unstable
DOCKERHUB_PASSWORD: "$DOCKER_HUB_AUTH" # else it is from a tag (enforced by gitlab-ci rules)
rules: # hint: tags are references independent of branches
# Always tag with unstable, on release branch also tag with latest - |
if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]
then docker build -t $AURA_IMAGE_NAME:unstable .
else docker build -t $AURA_IMAGE_NAME -t $AURA_IMAGE_NAME:$CI_COMMIT_TAG .
fi
# TODO: maybe isolate docker build and docker push
- docker push "$AURA_IMAGE_NAME" --all-tags
rules:
- *release-rules - *release-rules
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH" # every commit on master/main branch should trigger a push to docker-hub as unstable without a release
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
exists: exists:
- Dockerfile - Dockerfile
before_script:
- mkdir -p ~/.docker
- >
echo "{ \"auths\": {
\"https://index.docker.io/v1/\": {
\"auth\": \"$(echo -n \"$DOCKERHUB_USER:$DOCKERHUB_PASSWORD\" | base64)\"
}
}}" >> ~/.docker/config.json
script:
- >
echo "Docker context: $DOCKER_CONTEXT"
&& echo "Dockerfile directory: $DOCKERFILE_DIR"
&& echo "Cache image: $BUILD_CACHE"
&& echo "Images:" $(echo $IMAGE | sed "s/name=//")
- '[[ -n "$DOCKERFILE_NAME" ]] && BUILDKIT_ARGS="$BUILDKIT_ARGS --frontend-opt filename=$DOCKERFILE_NAME"'
- echo $BUILDKIT_ARGS
- >
buildctl-daemonless.sh build --progress=plain
--frontend=dockerfile.v0 --local context=$DOCKER_CONTEXT --local dockerfile=$DOCKERFILE_DIR
--export-cache type=registry,mode=max,ref=$BUILD_CACHE
--import-cache type=registry,ref=$BUILD_CACHE
--output type=image,\"$IMAGE\",push=true
$BUILDKIT_ARGS
release_job: release_job:
stage: release stage: release
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment