Skip to content

jonashackt/gitlab-ci-docker-socket-binding-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example app for building inside GitLab CI - using Docker socket binding

This GitLab CI example needs a corresponding GitLab runner configuration - see https://github.com/jonashackt/gitlab-ci-stack#configure-a-docker-socket-binding-enabled-gitlab-runner-with-the-docker-executor

See .gitlab-ci.yml:

# One of the new trends in Continuous Integration/Deployment is to:
# (see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html)
#
# 1. Create an application image
# 2. Run tests against the created image
# 3. Push image to a remote registry
# 4. Deploy to a server from the pushed image

stages:
  - build
  - test
  - push
  - deploy

# see usage of Namespaces at https://docs.gitlab.com/ee/user/group/#namespaces
variables:
  REGISTRY_GROUP_PROJECT: $CI_REGISTRY/root/gitlab-ci-shell-example

# see how to login at https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#using-the-gitlab-container-registry
before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY

build-image:
  stage: build
  # the tag 'shell' advices only GitLab runners using this tag to pick up that job
  tags:
    - shell
  script:
    - docker build . --tag $REGISTRY_GROUP_PROJECT/gitlab-ci-shell-example:latest

test-image:
  stage: test
  tags:
    - shell
  script:
    - echo Insert fancy API test here!

push-image:
  stage: push
  tags:
    - shell
  script:
    - docker push $REGISTRY_GROUP_PROJECT/gitlab-ci-shell-example:latest

deploy-2-dev:
  stage: deploy
  tags:
    - shell
  script:
    - echo You should use Ansible here!
  environment:
    name: dev
    url: https://dev.jonashackt.io


Swagger REST-API-Documentation

Start the app and go to http://localhost:8080/v2/api-docs to see all endpoints as JSON.

UI-Documentation you will find under http://localhost:8080/swagger-ui.html.

About

Example project using GitLab CI docker executor with binding the Host's Docker engine into it instead of using Docker-in-Docker (as with https://github.com/jonashackt/gitlab-ci-dind-example)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published