1
0
hugo/old/2016-06-17-gitlab-docker-build.md
2024-12-21 23:10:54 +09:00

1.4 KiB

+++ date = "2016-06-17" tags = ["pc"] title = "gitlab-docker-build" slug = "gitlab-docker-build" +++

GitLabがDockerとの連携機能を提供しはじめたのでDockerを使ってのビルドやテスト、プッシュが簡単になりました。

http://docs.gitlab.com/ce/ci/docker/using_docker_build.html


$ sudo docker ps -a
$ sudo systemctl start docker
$ docker login registry.gitlab.com
$ mkdir -p ~/docker/reponame/Dockerfile
$ cd ~/docker/reponame
$ sudo docker build -t registry.example.com/group/project .
$ sudo docker tag my-image my-registry:5000/my-image
$ sudo docker run my-docker-image /script/to/run/tests
$ sudo docker push registry.example.com/group/project

.gitlab-ci.ymlをこんな感じで書けるようになります。


build_image:
  image: docker:git
  services:
  - docker:dind
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.example.com
    - docker build -t registry.example.com/my-group/my-project .
    - docker run registry.example.com/my-group/my-project /script/to/run/tests
    - docker push registry.example.com/my-group/my-project:latest
  only:
    - master

https://about.gitlab.com/2016/05/23/gitlab-container-registry/