-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
38 lines (30 loc) · 1004 Bytes
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
variables:
GIT_DEPTH: 1
GOPROXY: "https://goproxy.cn,direct"
stages:
- build
- make
build_binary:
image: golang:alpine
stage: build
script:
- CGO_ENABLED=0 go build app.go
artifacts:
when: on_success
paths:
- ./app
make_image:
stage: make
before_script:
- docker login "$DOCKER_REPOSITORY_ALI" -u="$DOCKER_USERNAME_ALI" -p="$DOCKER_PASSWORD_ALI"
script:
- sed -i "s/blog:\w\+-BE/blog:$CI_COMMIT_SHORT_SHA-BE/g" docker-compose.yml
- docker build -f ./Dockerfile .
--build-arg ALI_AK="$ALI_AK"
--build-arg ALI_SK="$ALI_SK"
--build-arg ALI_ENDPOINT="$ALI_ENDPOINT"
--build-arg ALI_BUCKET="$ALI_BUCKET"
-t "$DOCKER_REPOSITORY_ALI"/calabash/blog:"$CI_COMMIT_SHORT_SHA"-BE
- docker push $DOCKER_REPOSITORY_ALI/calabash/blog:$CI_COMMIT_SHORT_SHA-BE
- scp -P $SSH_PORT ./docker-compose.yml deploy-server:~/deploy/blog/be
- ssh deploy-server -p $SSH_PORT "cd ~/deploy/blog/be && docker-compose up -d"