{"id":16179284,"url":"https://github.com/jonashackt/gitlab-ci-dind-example","last_synced_at":"2025-08-26T12:04:45.089Z","repository":{"id":147269794,"uuid":"203782874","full_name":"jonashackt/gitlab-ci-dind-example","owner":"jonashackt","description":"Example project using GitLab CI docker executor instead of shell executor (as in https://github.com/jonashackt/restexamples)","archived":false,"fork":false,"pushed_at":"2024-08-26T17:30:25.000Z","size":15,"stargazers_count":23,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T16:30:55.033Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonashackt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-22T11:40:00.000Z","updated_at":"2024-07-12T00:06:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"f729dc24-6053-4726-9271-d62d7a6c3771","html_url":"https://github.com/jonashackt/gitlab-ci-dind-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonashackt/gitlab-ci-dind-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgitlab-ci-dind-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgitlab-ci-dind-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgitlab-ci-dind-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgitlab-ci-dind-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonashackt","download_url":"https://codeload.github.com/jonashackt/gitlab-ci-dind-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fgitlab-ci-dind-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272218866,"owners_count":24894296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T05:26:35.424Z","updated_at":"2025-08-26T12:04:45.069Z","avatar_url":"https://github.com/jonashackt.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Example app for building inside GitLab CI - using Docker-in-Docker\n=============================\n\nThis GitLab CI example needs a corresponding GitLab runner configuration - see https://github.com/jonashackt/gitlab-ci-stack#configure-a-docker-in-docker-enabled-gitlab-runner-with-the-docker-executor\n\nSee [.gitlab-ci.yml](.gitlab-ci.yml):\n\n```\n# This .gitlab-ci.yml is an extension of the example provided in: \n# https://github.com/jonashackt/restexamples/blob/master/.gitlab-ci.yml\n# We use Docker in Docker here with a docker executor instead of the shell one\n# --\u003e Pinning the right Docker version for the service\nimage: docker:19.03.1\n\n# Pinning the right Docker version for the service also\nservices:\n  - docker:19.03.1-dind\n\nvariables:\n  # see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled for Dind configuration\n  # DOCKER_HOST: tcp://docker:2375 --\u003e this should only be configured when using Kubernetes runners\n  # When using dind, it's wise to use the overlayfs driver for\n  # improved performance.\n  DOCKER_DRIVER: overlay2\n  # Specify to Docker where to create the certificates, Docker will\n  # create them automatically on boot, and will create\n  # `/certs/client` that will be shared between the service and job\n  # container, thanks to volume mount from config.toml\n  DOCKER_TLS_CERTDIR: \"/certs\"\n  # see usage of Namespaces at https://docs.gitlab.com/ee/user/group/#namespaces\n  REGISTRY_GROUP_PROJECT: $CI_REGISTRY/root/gitlab-ci-dind-example\n\n# One of the new trends in Continuous Integration/Deployment is to:\n# (see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html)\n#\n# 1. Create an application image\n# 2. Run tests against the created image\n# 3. Push image to a remote registry\n# 4. Deploy to a server from the pushed image\n\nstages:\n  - build\n  - test\n  - push\n  - deploy\n\n# see how to login at https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#using-the-gitlab-container-registry\nbefore_script:\n  - docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY\n\nbuild-image:\n  stage: build\n  # the tag 'dind' advices only GitLab runners using this tag to pick up that job\n  tags: \n    - dind\n  script:\n    - docker build . --tag $REGISTRY_GROUP_PROJECT/gitlab-ci-dind-example:latest\n\ntest-image:\n  stage: test\n  tags:\n    - dind\n  script:\n    - echo Insert fancy API test here!\n\npush-image:\n  stage: push\n  tags:\n    - dind\n  script:\n    - docker push $REGISTRY_GROUP_PROJECT/gitlab-ci-dind-example:latest\n\ndeploy-2-dev:\n  stage: deploy\n  tags:\n    - dind\n  script:\n    - echo You should use Ansible here!\n  environment:\n    name: dev\n    url: https://dev.jonashackt.io\n\n\n```\n\n#### layer caching for Docker-in-Docker\n\nPossible optimisation: [Making docker-in-docker builds faster with Docker layer caching](https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#making-docker-in-docker-builds-faster-with-docker-layer-caching): As the Docker Engine used with Docker-in-Docker will download the images every time the pipeline starts a build, it will slow down your builds. Here the `--cache-from` argument of the `docker run` command can help.\n\n\n#### No modern full-Docker workflow possible!\n\nBig problem: The \"new trends in Continuous Integration/Deployment\" aren't applieable with Docker-in-Docker - those are:\n\n```\n# One of the new trends in Continuous Integration/Deployment is to:\n# (see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html)\n#\n# 1. Create an application image\n# 2. Run tests against the created image\n# 3. Push image to a remote registry\n# 4. Deploy to a server from the pushed image\n\nstages:\n  - build\n  - test\n  - push\n  - deploy\n``` \n\nSince we do our `docker build` inside the `build` stage - and the Pipeline tries to push the resulting Docker image in the `push` stage - but images aren't shared or kept up over stages - we can't implement this desired workflow. For more info, have a look at the overview ASCII art here: https://github.com/jonashackt/gitlab-ci-stack#configure-a-docker-in-docker-enabled-gitlab-runner-with-the-docker-executor\n\nOne possible workaround is to skip the 4 phases and do just a `build_push`, then `test` and then `deploy` - which brings the drawback of \"releasing\" un-tested images to our registry:\n\n```\nstages:\n  - build_push\n  - test\n  - deploy\n```\n\n\n### Simple REST Spring Boot app\n\nStart the app and go to [http://localhost:8080/v2/api-docs](http://localhost:8080/v2/api-docs) to see all endpoints as JSON.\n\nUI-Documentation you will find under [http://localhost:8080/swagger-ui.html](http://localhost:8080/swagger-ui.html).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fgitlab-ci-dind-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonashackt%2Fgitlab-ci-dind-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fgitlab-ci-dind-example/lists"}