Instantly share code, notes, and snippets.

@sh0umik sh0umik/.gitlab-ci.yml
Last active Sep 14, 2018

Embed
What would you like to do?
Gitlab CI for Golang and Docker in Docker
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