forked from event-storming/reqres_products
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
58 lines (53 loc) · 1.69 KB
/
.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
variables:
REPOSITORY: "xxxxxxxxxx.dkr.ecr.ap-northeast-2.amazonaws.com"
IMAGE_NAME: "$REPOSITORY/$CI_PROJECT_NAME"
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
image: docker:stable
services:
- docker:dind
cache:
paths:
- .m2/repository/
stages:
- build
- package
- deploy
build:
image: maven:3.3-jdk-8
stage: build
script:
- mvn clean package -Dmaven.test.skip=true
artifacts:
paths:
- target/*SNAPSHOT.jar
package:
stage: package
script:
- docker info
- apk add --no-cache curl jq python py-pip
- pip install awscli
- docker build -t $IMAGE_NAME:${CI_COMMIT_SHA} .
- $(aws ecr get-login --no-include-email --region ap-northeast-2)
- docker push $IMAGE_NAME:${CI_COMMIT_SHA}
tags:
- dind
deploy_dev:
stage: deploy
image: alpine
only:
- master
script:
- apk add --no-cache curl
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- mv ./kubectl /usr/local/bin/kubectl
- kubectl config set-cluster k8s --server="$KUBE_URL" --insecure-skip-tls-verify=true
- kubectl config set-credentials admin --token="$KUBE_TOKEN"
- kubectl config set-context default --cluster=k8s --user=admin
- kubectl config use-context default
- sed -i "s/_PROJECT_NAME/$CI_PROJECT_NAME/" deployment.yaml service.yaml
- sed -i "s/_REPOSITORY/$REPOSITORY/" deployment.yaml service.yaml
- sed -i "s/_VERSION/${CI_COMMIT_SHA}/" deployment.yaml service.yaml
- kubectl apply -f deployment.yaml
- kubectl apply -f service.yaml