Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Tung Nguyen
gitlab-k8s-python-demo
Commits
f0abb03b
Commit
f0abb03b
authored
May 16, 2019
by
Ijaz Ahmad
Browse files
adds CI file
parent
20f5e58c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
.gitlab-ci.yml
.gitlab-ci.yml
+70
-0
No files found.
.gitlab-ci.yml
0 → 100644
View file @
f0abb03b
# Author , IjazAhmad
# iahmad@ebi.ac.uk
image
:
docker:latest
stages
:
-
build
-
test
-
deploy
services
:
-
docker:dind
variables
:
CI_REGISTRY
:
dockerhub.ebi.ac.uk
CI_REGISTRY_IMAGE
:
$CI_REGISTRY/$CI_PROJECT_PATH
DOCKER_DRIVER
:
overlay2
before_script
:
-
docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
docker-build
:
stage
:
build
script
:
-
docker pull $CI_REGISTRY_IMAGE:latest ||
true
-
docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .
docker-push
:
stage
:
build
script
:
-
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
-
docker push $CI_REGISTRY_IMAGE:latest
unit-tests
:
stage
:
test
script
:
-
echo "running unit tests on the image"
-
docker run $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA ./test_app.py
sast
:
stage
:
test
script
:
-
echo "running security testing on the image"
testing
:
stage
:
deploy
script
:
-
sed -i "s|CI_IMAGE|$CI_REGISTRY_IMAGE|g" kubernetes.yaml.tpl
-
sed -i "s|TAG|$CI_COMMIT_SHA|g" kubernetes.yaml.tpl
-
kubectl apply --namespace webproduction-test -f kubernetes.yaml.tpl
environment
:
name
:
testing
url
:
https://testing.example.com
only
:
-
branches
production
:
stage
:
deploy
script
:
-
sed -i "s|CI_IMAGE|$CI_REGISTRY_IMAGE|g" kubernetes.yaml.tpl
-
sed -i "s|TAG|$CI_COMMIT_SHA|g" kubernetes.yaml.tpl
-
kubectl apply --namespace webproduction-prod -f kubernetes.yaml.tpl
environment
:
name
:
production
url
:
https://production.example.com
when
:
manual
only
:
-
master
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment