Newer
Older
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
stages:
- prebuild
- build
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
variables:
GIT_SUBMODULE_STRATEGY: recursive
BASE_IMAGE: build-base:latest
CARGO_INCREMENTAL: 0
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo
#
# See also:
# GitLab CI/CD predefined variables
# https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
#
# CI_COMMIT_SHA: The commit revision the project is built for
# CI_REGISTRY: The address of the GitLab Container Registry
# CI_REGISTRY_USER: The username to push containers to the project’s
# GitLab Container Registry
# CI_REGISTRY_PASSWORD: The password to push containers to the project’s
# GitLab Container Registry
# CI_REGISTRY_IMAGE: The address of the project’s Container Registry
docker-build-base:
stage: prebuild
image: docker:20
tags:
- docker
services:
- docker:dind
rules:
- # if
changes:
- docker-build-base/Dockerfile
before_script:
- >
echo -n ${CI_REGISTRY_PASSWORD} | docker login
-u ${CI_REGISTRY_USER}
--password-stdin
${CI_REGISTRY}
script:
- docker pull ${CI_REGISTRY_IMAGE}/${BASE_IMAGE} || true
- >
docker build
--pull
--label GIT_COMMIT=${CI_COMMIT_SHA}
--cache-from ${CI_REGISTRY_IMAGE}/${BASE_IMAGE}
-t ${CI_REGISTRY_IMAGE}/${BASE_IMAGE}
-f ./docker-build-base/Dockerfile
./docker-build-base
- docker push ${CI_REGISTRY_IMAGE}/${BASE_IMAGE}
build:
image: ${CI_REGISTRY_IMAGE}/${BASE_IMAGE}
stage: build
script:
- cargo -V
- cargo build
- cargo test
cache:
paths:
- target
- Cargo.lock
- .cargo