-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy path.gitlab-ci.yml
103 lines (94 loc) · 3.03 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
variables:
SERVER_DIST_IMAGE: "$CI_REGISTRY_IMAGE/server-dist:$CI_COMMIT_REF_SLUG"
SERVER_DIST_IMAGE_SHA: "$CI_REGISTRY_IMAGE/server-dist:$CI_COMMIT_SHA"
CLIENT_DIST_IMAGE: "$CI_REGISTRY_IMAGE/client-dist:$CI_COMMIT_REF_SLUG"
CLIENT_DIST_IMAGE_SHA: "$CI_REGISTRY_IMAGE/client-dist:$CI_COMMIT_SHA"
DIST_IMAGE_LATEST: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
DIST_IMAGE_SHA: "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
DIST_IMAGE_DOCKER_HUB: "mediathekview/mediathekviewweb:latest"
DIST_IMAGE_DOCKER_HUB_DEVELOPMENT: "mediathekview/mediathekviewweb:development"
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
stages:
- build:dependencies
- build:application
- pack
- publish
build:server:
stage: build:application
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
except:
- schedules
script:
- /kaniko/executor --cache=true
--context "$CI_PROJECT_DIR"
--dockerfile "$CI_PROJECT_DIR/ci/server.dockerfile"
--destination "$SERVER_DIST_IMAGE_SHA"
--destination "$SERVER_DIST_IMAGE"
tags:
- gitlab-org-docker
build:client:
stage: build:application
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
except:
- schedules
script:
- /kaniko/executor --cache=true
--context "$CI_PROJECT_DIR"
--dockerfile "$CI_PROJECT_DIR/ci/client.dockerfile"
--destination "$CLIENT_DIST_IMAGE_SHA"
--destination "$CLIENT_DIST_IMAGE"
tags:
- gitlab-org-docker
pack:dist:
stage: pack
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
except:
- schedules
script:
- /kaniko/executor --cache=true
--context "$CI_PROJECT_DIR"
--dockerfile "$CI_PROJECT_DIR/ci/dist.dockerfile"
--build-arg "SERVER_DIST_IMAGE=$SERVER_DIST_IMAGE_SHA"
--build-arg "CLIENT_DIST_IMAGE=$CLIENT_DIST_IMAGE_SHA"
--destination "$DIST_IMAGE_SHA"
--destination "$DIST_IMAGE_LATEST"
tags:
- gitlab-org-docker
publish:image:
stage: publish
when: manual
image: alpine:3.18
only:
- master
except:
- schedules
script:
- apk add --no-cache skopeo
- skopeo login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- skopeo login --username "$DOCKER_HUB_USER" --password "$DOCKER_HUB_PASSWORD" "docker.io"
- skopeo copy "docker://${DIST_IMAGE_SHA}" "docker://${DIST_IMAGE_DOCKER_HUB}"
tags:
- gitlab-org-docker
publish:image-development:
stage: publish
when: manual
image: alpine:3.18
only:
- development
except:
- schedules
script:
- apk add --no-cache skopeo
- skopeo login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- skopeo login --username "$DOCKER_HUB_USER" --password "$DOCKER_HUB_PASSWORD" "docker.io"
- skopeo copy "docker://${DIST_IMAGE_SHA}" "docker://${DIST_IMAGE_DOCKER_HUB_DEVELOPMENT}"
tags:
- gitlab-org-docker