-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
48 lines (39 loc) · 1.35 KB
/
.gitlab-ci.yml
File metadata and controls
48 lines (39 loc) · 1.35 KB
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
stages: # List of stages for jobs, and their order of execution
- build
- test
- push
services:
- docker:20.10.16-dind
variables:
DOCKER_IMAGE_NAME: devops-training-flask-app
CI_REGISTRY: docker.io
before_script:
- env
- docker login -u "$DOCKERHUB_USERNAME" -p "$DOCKERHUB_TOKEN" $CI_REGISTRY
build-job:
stage: build
image: docker:20.10.16
script:
- docker build --file tests.Dockerfile -t "$DOCKER_IMAGE_NAME-tests" .
- docker build --file Dockerfile -t "$DOCKER_IMAGE_NAME" .
- echo "Running unit tests... This will take about 60 seconds."
- docker run "$DOCKER_IMAGE_NAME-tests"
- echo "Pushing image..."
- docker tag $DOCKER_IMAGE_NAME $CI_REGISTRY_IMAGE_BASE/$DOCKER_IMAGE_NAME:latest
- docker push $CI_REGISTRY_IMAGE_BASE/$DOCKER_IMAGE_NAME:latest
# unit-test-job:
# stage: test
# image: docker:20.10.16
# script:
# - echo "Running unit tests... This will take about 60 seconds."
# - docker run "$DOCKER_IMAGE_NAME-tests"
# push-job:
# stage: push
# image: docker:20.10.16
# script:
# - echo "Pushing image..."
# - docker tag $DOCKER_IMAGE_NAME $CI_REGISTRY_IMAGE_BASE/$DOCKER_IMAGE_NAME:latest
# - docker push $CI_REGISTRY_IMAGE_BASE/$DOCKER_IMAGE_NAME:latest
# only:
# - develop
# - master