From b30c0a9784bc194db73b28d48e2da33d1b21fca3 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Fri, 9 May 2025 20:17:04 +0100 Subject: [PATCH] Add gitlab CI config --- .gitlab-ci.yml | 36 ++++++++++++++++++++++++++++++++++++ Dockerfile | 2 ++ 2 files changed, 38 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..fdb7038 --- /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 3cd9a00..8d571fe 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 \ -- GitLab