diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..fdb7038666ba6d9ef490775896cafea1046e3f16 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,36 @@ +# GitLab CI configuration for building and publishing Docker images + +stages: + - build + +variables: + # Docker image name based on the GitLab project path + IMAGE_NAME: ${CI_REGISTRY_IMAGE} + # Use Docker BuildKit for better performance + DOCKER_BUILDKIT: 1 + # Build arguments + DOCKER_BUILD_ARGS: "" + +# Build and publish Docker image when a tag is pushed +build-and-publish: + stage: build + image: docker:latest + services: + - docker:dind + # Only run this job when a tag is pushed + rules: + - if: $CI_COMMIT_TAG + before_script: + # Log in to the GitLab Container Registry + - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY + script: + # Build the Docker image with the tag as version + - docker build --pull ${DOCKER_BUILD_ARGS} -t ${IMAGE_NAME}:${CI_COMMIT_TAG} . + # Push the versioned tag + - docker push ${IMAGE_NAME}:${CI_COMMIT_TAG} + - echo "Docker image '${IMAGE_NAME}:${CI_COMMIT_TAG}' was built and pushed to the registry" + # Cache Docker layers between jobs + cache: + key: ${CI_COMMIT_REF_SLUG} + paths: + - .docker-cache/ diff --git a/Dockerfile b/Dockerfile index 3cd9a000ec91c03a7a5aba8df46dfab1ae246883..8d571febaa1b5c0e2a7382a958a3249c6af97fb7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ # Use cimg/android:2025.04-ndk as the base image FROM cimg/android:2025.04-ndk +USER root + # Set environment variables ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \