Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-conversion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
query-conversion
Commits
ae78d1f7
Commit
ae78d1f7
authored
3 years ago
by
Geurtjens,D. (Douwe Geurtjens)
Browse files
Options
Downloads
Patches
Plain Diff
pipeline config
parent
1bef7859
No related branches found
No related tags found
1 merge request
!1
Big merge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+85
-0
85 additions, 0 deletions
.gitlab-ci.yml
with
85 additions
and
0 deletions
.gitlab-ci.yml
0 → 100644
+
85
−
0
View file @
ae78d1f7
image
:
golang:1.16
stages
:
-
test
-
docker
-
deploy
lint
:
stage
:
test
script
:
-
make lint
unit_tests
:
stage
:
test
script
:
-
make dep
-
make test
docker
:
image
:
docker:stable
tags
:
-
docker
stage
:
docker
only
:
-
develop
-
main
before_script
:
# Make sure docker uses Buildkit
-
export DOCKER_BUILDKIT=1
# Log full docker build progress
-
export BUILDKIT_PROGRESS=plain
# Enable experimental features (buildx)
-
export DOCKER_CLI_EXPERIMENTAL=enabled
# Install docker buildx
-
mkdir -p $HOME/.docker/cli-plugins
-
wget -O $HOME/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.4.2/buildx-v0.4.2.linux-amd64
-
chmod a+x $HOME/.docker/cli-plugins/docker-buildx
# Log in to our private image registry
-
docker login datastropheregistry.azurecr.io -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
-
docker buildx install
-
docker buildx create --use
# Install openssh and curl
-
apk add openssh-client curl
-
mkdir ~/.ssh/
-
eval $(ssh-agent -s)
-
echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
-
chmod 600 ~/.ssh/id_rsa
# Add our private ssh key
-
ssh-add ~/.ssh/id_rsa
# Add UU gitlab to known hosts
-
echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
-
chmod 644 ~/.ssh/known_hosts
script
:
# Build and push image for linux/amd64 as well as linux/arm64
# Check if $CI_COMMIT_BRANCH is available, as it is not if this is a merge pipeline run
-
if [[ ! -z $CI_COMMIT_BRANCH+x ]]; then DOCKER_TAG=$CI_COMMIT_BRANCH; else DOCKER_TAG=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME; fi
-
docker buildx build --platform linux/amd64,linux/arm64 -t datastropheregistry.azurecr.io/$CI_PROJECT_NAME:$DOCKER_TAG . --push --ssh default
deploy
:
stage
:
deploy
only
:
-
develop
-
main
script
:
-
apt-get install openssh-client curl -y >/dev/null
-
mkdir ~/.ssh/
-
eval $(ssh-agent -s)
-
echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
-
chmod 600 ~/.ssh/id_rsa
-
ssh-add ~/.ssh/id_rsa
-
echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
-
chmod 644 ~/.ssh/known_hosts
-
ssh -fN -L 1234:science-vs260.science.uu.nl:22 sivan@up.science.uu.nl
# Copy kubernetes files over
-
scp -r -o StrictHostKeyChecking=no -P 1234 -i ~/.ssh/id_rsa deployments/* root@localhost:/root/kubernetes/$CI_PROJECT_NAME
# Deploy all yml files
-
ssh -p 1234 -i ~/.ssh/id_rsa root@localhost "kubectl apply -f kubernetes/$CI_PROJECT_NAME/"
# Set deployment image to the image we just made
-
if [[ ! -z $CI_COMMIT_BRANCH+x ]]; then DOCKER_TAG=$CI_COMMIT_BRANCH; else DOCKER_TAG=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME; fi
# Restart the deployment if the image is not changed
-
ssh -p 1234 -i ~/.ssh/id_rsa root@localhost "if kubectl set image deployment/$DEPLOYMENT_NAME $DEPLOYMENT_NAME=datastropheregistry.azurecr.io/$CI_PROJECT_NAME:$DOCKER_TAG | grep -q "image updated";
then
kubectl rollout restart deployment/$DEPLOYMENT_NAME;
fi"
dependencies
:
[]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Heijden,T.A.J. van der (Thijs)
@t.a.j.vanderheijden
mentioned in commit
82d6956b
·
3 years ago
mentioned in commit
82d6956b
mentioned in commit 82d6956b25f2a5a9942b9ef3014309c1aefed134
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment