Last active
October 19, 2021 14:55
-
-
Save Nihhaar/5202d49e8ac79f9a3d1e7c5496205dde to your computer and use it in GitHub Desktop.
Gitlab CI DinD + ECR
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
image: docker | |
variables: | |
DOCKER_HOST: tcp://docker:2375/ | |
DOCKER_DRIVER: overlay2 | |
DOCKER_TLS_CERTDIR: "" | |
services: | |
- docker:dind | |
before_script: | |
- apk update | |
- apk add --no-cache docker-compose | |
- mkdir $HOME/.docker | |
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json | |
test: | |
script: | |
- docker-compose -f scripts/ci/docker-compose-ci.yml up --abort-on-container-exit |
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
concurrent = 1 | |
check_interval = 0 | |
[session_server] | |
session_timeout = 1800 | |
[[runners]] | |
name = "Gitlab Runner" | |
url = "https://gitlab.com/" | |
token = "token" | |
executor = "docker" | |
environment = ["DOCKER_AUTH_CONFIG={ \"credsStore\": \"ecr-login\" }"] | |
[runners.custom_build_dir] | |
[runners.cache] | |
[runners.cache.s3] | |
[runners.cache.gcs] | |
[runners.cache.azure] | |
[runners.docker] | |
tls_verify = false | |
image = "docker" | |
privileged = true | |
disable_entrypoint_overwrite = false | |
oom_kill_disable = false | |
disable_cache = false | |
volumes = [ | |
"/cache", | |
"/usr/local/bin/docker-credential-ecr-login:/usr/local/bin/docker-credential-ecr-login" | |
] | |
shm_size = 0 |
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
# source: https://mrkaran.dev/posts/gitlab-runner-ecr/ | |
# with some tweaks | |
FROM ubuntu:20.04 AS build | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN : \ | |
&& apt-get update \ | |
&& apt-get install --no-install-recommends -y git golang-go ca-certificates \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
; | |
RUN go get -u github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login | |
WORKDIR /build | |
RUN mv /root/go/bin/docker-credential-ecr-login . | |
FROM gitlab/gitlab-runner:v13.8.0 AS deploy | |
COPY --from=build /build/docker-credential-ecr-login /usr/local/bin/docker-credential-ecr-login | |
# Tweaks (install vim) | |
RUN : \ | |
&& apt-get update \ | |
&& apt-get install --no-install-recommends -y vim \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
; | |
# Tweaks (without this ecr won't work) | |
ARG AWS_DEFAULT_REGION="ap-south-1" | |
ENV AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment