Last active
April 20, 2019 20:14
-
-
Save sh0umik/20d16d9a99d3b0eda4e4cfaa0f14ac7b to your computer and use it in GitHub Desktop.
Gitlab CI for Golang and Docker in Docker
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: restra/golang-docker-gitlabci | |
variables: | |
DOCKER_REPO: registry.gitlab.com | |
MAIN_IMAGE_NAME: sh0umik/golang-gitlab-ci | |
services: | |
- docker:dind | |
stages: | |
- build | |
- upgrade | |
before_script: | |
- mkdir -p /go/src/gitlab.com/sh0umik/golang-gitlab-ci | |
- cp -r . /go/src/gitlab.com/sh0umik/golang-gitlab-ci | |
- cd /go/src/gitlab.com/sh0umik/golang-gitlab-ci | |
build: | |
stage: build | |
script: | |
- glide up | |
- CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo . | |
- docker login -u fahim.shoumik -p $ACCESS_TOKEN $DOCKER_REPO | |
- docker build -t $DOCKER_REPO/$MAIN_IMAGE_NAME:latest . | |
- docker build -t $DOCKER_REPO/$MAIN_IMAGE_NAME:$CI_COMMIT_REF_NAME . | |
- docker push $DOCKER_REPO/$MAIN_IMAGE_NAME:latest | |
- docker push $DOCKER_REPO/$MAIN_IMAGE_NAME:$CI_COMMIT_REF_NAME | |
upgrade: | |
stage: upgrade | |
script: | |
- echo "upgrade here" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment