emk / rust-musl-builder

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.
Apache License 2.0
1.54k stars 193 forks source link

Add example .gitlabb-ci.yml #102

Closed NyxCode closed 2 years ago

NyxCode commented 4 years ago

I really appreciate your work, this has been tremendously usefull for me! I am using the image in Gitlab CI, but it's not obvious to me how to get caching to work. A brief example for this would be great!

emk commented 4 years ago

This is an excellent suggestion! Unfortunately, I don't know much about GitLab.

Generally speaking, all you need is a working Docker setup on your runner, and you can then adapt the build-release script as needed.

OliverEvans96 commented 3 years ago

Here's a minimal .gitlab-ci.yml that has worked for me:

stages:
  - build

build-image:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
      # Tag images with git commit SHAs
    - /kaniko/executor --context $CI_PROJECT_DIR --destination $CI_REGISTRY_IMAGE:latest --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA --build-arg SRC_COMMIT=$CI_COMMIT_SHORT_SHA -v warn

However, I wouldn't think caching has anything to do with the particular base image you start building from (rust-musl-builder), but rather the image you're building in, which would be dind, kaniko, buildah, or something similar. You'll probably have more luck opening an issue in one of those repos, or with the Gitlab Runner itself.

Cheers, Oliver