2017-08-24 17:27:03 +05:30
|
|
|
|
# Предполагается, что между работой "build docker container" и этапом push
|
|
|
|
|
# построенные docker images остаются статичными и никуда не пропадают
|
|
|
|
|
#
|
|
|
|
|
# В противном случае их нужно после каждого этапа билда пушить в registry
|
|
|
|
|
|
2016-12-03 04:35:23 +05:30
|
|
|
|
stages:
|
2017-08-24 17:27:03 +05:30
|
|
|
|
- test
|
|
|
|
|
- build
|
|
|
|
|
- build_docker_image
|
|
|
|
|
- push
|
|
|
|
|
- cleanup
|
2016-12-03 04:35:23 +05:30
|
|
|
|
|
|
|
|
|
variables:
|
2017-08-24 17:27:03 +05:30
|
|
|
|
CONTAINER_IMAGE: registry.ely.by/elyby/skinsystem
|
|
|
|
|
|
|
|
|
|
.golang_template: &setup_go_environment
|
2017-09-05 02:26:10 +05:30
|
|
|
|
image: golang:1.9.0-alpine3.6
|
2017-08-24 17:27:03 +05:30
|
|
|
|
before_script:
|
2017-09-05 02:26:10 +05:30
|
|
|
|
- apk add --no-cache git
|
2017-08-24 17:27:03 +05:30
|
|
|
|
- mkdir -p $GOPATH/src/$CI_PROJECT_NAMESPACE
|
|
|
|
|
- cp -r $(pwd) $GOPATH/src/$CI_PROJECT_PATH
|
|
|
|
|
- cd $GOPATH/src/$CI_PROJECT_PATH
|
|
|
|
|
- go get -u github.com/golang/dep/cmd/dep
|
|
|
|
|
- $GOPATH/bin/dep ensure
|
|
|
|
|
|
|
|
|
|
.docker_template: &setup_docker_environment
|
|
|
|
|
image: docker:latest
|
|
|
|
|
before_script:
|
2017-09-11 16:47:28 +05:30
|
|
|
|
- docker login -u gitlab-ci -p $CI_JOB_TOKEN registry.ely.by
|
2017-08-24 17:27:03 +05:30
|
|
|
|
- export TEMP_IMAGE_NAME="$CONTAINER_IMAGE:$CI_PIPELINE_ID"
|
2016-12-03 04:35:23 +05:30
|
|
|
|
|
2017-08-18 03:43:24 +05:30
|
|
|
|
test:
|
2017-08-24 17:27:03 +05:30
|
|
|
|
<<: *setup_go_environment
|
|
|
|
|
stage: test
|
|
|
|
|
script:
|
|
|
|
|
- ./script/coverage
|
|
|
|
|
|
|
|
|
|
build executable:
|
|
|
|
|
<<: *setup_go_environment
|
|
|
|
|
stage: build
|
|
|
|
|
script:
|
2017-09-11 16:47:28 +05:30
|
|
|
|
- export VERSION="${CI_COMMIT_TAG:-dev-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}+build-$CI_JOB_ID}"
|
2017-09-03 00:07:16 +05:30
|
|
|
|
- >
|
|
|
|
|
env GOOS=linux
|
|
|
|
|
go build
|
|
|
|
|
-o $CI_PROJECT_DIR/minecraft-skinsystem
|
2017-09-11 16:47:28 +05:30
|
|
|
|
-ldflags "-X ${CI_PROJECT_PATH}/bootstrap.version=${VERSION}"
|
2017-09-03 00:07:16 +05:30
|
|
|
|
main.go
|
2017-08-24 17:27:03 +05:30
|
|
|
|
artifacts:
|
|
|
|
|
name: "${CI_JOB_STAGE} executable"
|
|
|
|
|
paths:
|
|
|
|
|
- $CI_PROJECT_DIR/minecraft-skinsystem
|
|
|
|
|
expire_in: 1 day
|
|
|
|
|
|
|
|
|
|
build docker image:
|
|
|
|
|
<<: *setup_docker_environment
|
|
|
|
|
stage: build_docker_image
|
|
|
|
|
script:
|
2017-09-04 22:54:55 +05:30
|
|
|
|
- docker build -t $TEMP_IMAGE_NAME -f docker/Dockerfile .
|
2017-08-24 17:27:03 +05:30
|
|
|
|
only:
|
|
|
|
|
- tags
|
|
|
|
|
- develop
|
|
|
|
|
|
|
|
|
|
push dev:
|
|
|
|
|
<<: *setup_docker_environment
|
|
|
|
|
stage: push
|
2017-08-24 17:40:30 +05:30
|
|
|
|
variables:
|
|
|
|
|
GIT_STRATEGY: none
|
2017-08-24 17:27:03 +05:30
|
|
|
|
script:
|
|
|
|
|
- export IMAGE_NAME="$CONTAINER_IMAGE:dev"
|
|
|
|
|
- docker tag $TEMP_IMAGE_NAME $IMAGE_NAME
|
|
|
|
|
- docker push $IMAGE_NAME
|
|
|
|
|
only:
|
|
|
|
|
- develop
|
|
|
|
|
|
|
|
|
|
push tag:
|
|
|
|
|
<<: *setup_docker_environment
|
|
|
|
|
stage: push
|
2017-08-24 17:40:30 +05:30
|
|
|
|
variables:
|
|
|
|
|
GIT_STRATEGY: none
|
2017-08-24 17:27:03 +05:30
|
|
|
|
script:
|
2017-09-11 16:47:28 +05:30
|
|
|
|
- export IMAGE_NAME="$CONTAINER_IMAGE:$CI_COMMIT_TAG"
|
2017-08-24 17:27:03 +05:30
|
|
|
|
- export LATEST_IMAGE_NAME="$CONTAINER_IMAGE:latest"
|
|
|
|
|
- docker tag $TEMP_IMAGE_NAME $IMAGE_NAME
|
|
|
|
|
- docker tag $TEMP_IMAGE_NAME $LATEST_IMAGE_NAME
|
|
|
|
|
- docker push $IMAGE_NAME
|
|
|
|
|
- docker push $LATEST_IMAGE_NAME
|
|
|
|
|
only:
|
|
|
|
|
- tags
|
|
|
|
|
|
|
|
|
|
cleanup temp image:
|
|
|
|
|
<<: *setup_docker_environment
|
|
|
|
|
stage: cleanup
|
|
|
|
|
when: always
|
|
|
|
|
script:
|
2017-08-24 17:34:52 +05:30
|
|
|
|
- docker rmi $TEMP_IMAGE_NAME || true
|