Created
November 6, 2020 15:46
-
-
Save frafra/12a27ddbcaba5fea951e9af0d0037768 to your computer and use it in GitHub Desktop.
Build containers with GitLab CI without root nor daemons by using buildkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build-container: | |
stage: build | |
image: | |
name: moby/buildkit:rootless | |
entrypoint: [ "sh", "-c" ] | |
variables: | |
BUILDKITD_FLAGS: --oci-worker-no-process-sandbox | |
before_script: | |
- | | |
mkdir ~/.docker | |
auth=$(echo -n "$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD" | base64) | |
echo "{\"auths\": {\"$CI_REGISTRY\": {\"auth\": \"$auth\"}}}" > ~/.docker/config.json | |
script: | |
- | | |
buildctl-daemonless.sh build \ | |
--frontend=dockerfile.v0 \ | |
--local context=. \ | |
--local dockerfile=. \ | |
--import-cache type=registry,ref=$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG \ | |
--export-cache type=inline \ | |
--output type=image,name=$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG,push=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The runner still needs to be privileged, otherwise I get
Did anyone manage to run this without privileged?