Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
oetzit
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
Releases
Package Registry
Container 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
commul
oetzit
Commits
244ccad1
Commit
244ccad1
authored
3 years ago
by
Paolo.Brasolin
Browse files
Options
Downloads
Patches
Plain Diff
ci: clean up #be deploy job
parent
b7072297
No related branches found
No related tags found
No related merge requests found
Pipeline
#23185
failed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+144
-158
144 additions, 158 deletions
.gitlab-ci.yml
ci/install-kubectl-on-alpine.sh
+38
-0
38 additions, 0 deletions
ci/install-kubectl-on-alpine.sh
with
182 additions
and
158 deletions
.gitlab-ci.yml
+
144
−
158
View file @
244ccad1
variables
:
variables
:
DOCKER_TLS_CERTDIR
:
"
"
# HACK: see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
DOCKER_TLS_CERTDIR
:
"
"
# HACK: see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
DOCKER_IMAGE
:
"
docker:20.10.12"
DOCKER_IMAGE
:
"
docker:20.10.12"
stages
:
stages
:
-
build
-
build
-
deploy
-
deploy
#==[ Backend build ]============================================================
#==[ Backend build ]============================================================
# TODO: cache docker layers
# TODO: cache docker layers
# TODO: build ts
# TODO: build ts
be-build-job
:
be-build-job
:
image
:
$DOCKER_IMAGE
image
:
$DOCKER_IMAGE
stage
:
build
stage
:
build
tags
:
tags
:
-
commul
-
commul
services
:
services
:
-
docker:dind
-
docker:dind
variables
:
variables
:
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
before_script
:
before_script
:
-
docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN https://$CI_REGISTRY
-
docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN https://$CI_REGISTRY
script
:
script
:
-
>
-
>
docker build
docker build
--rm --no-cache
--rm --no-cache
--target production
--target production
--tag=$IMAGE_NAME:${CI_COMMIT_SHA}
--tag=$IMAGE_NAME:${CI_COMMIT_SHA}
--tag=$IMAGE_NAME:${CI_COMMIT_REF_NAME}
--tag=$IMAGE_NAME:${CI_COMMIT_REF_NAME}
--tag=$IMAGE_NAME:${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
--tag=$IMAGE_NAME:${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
backend
backend
-
docker image push --all-tags $IMAGE_NAME
-
docker image push --all-tags $IMAGE_NAME
only
:
only
:
-
tags
-
tags
-
development
-
development
#==[ Backend deployment ]=======================================================
#==[ Backend deployment ]=======================================================
.be-deploy-job
:
.be-deploy-job
:
image
:
alpine:latest
image
:
alpine:latest
# image: $DOCKER_IMAGE
stage
:
deploy
stage
:
deploy
needs
:
needs
:
-
job
:
be-build-job
-
job
:
be-build-job
artifacts
:
false
artifacts
:
false
# TODO: maybe we can get the build image as an artifact?
tags
:
tags
:
-
commul
-
commul
variables
:
# services:
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
# - docker:dind
before_script
:
variables
:
-
./ci/install-kubectl-on-alpine.sh
KUBECTL_VERSION
:
v1.8.10
script
:
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
-
kubectl set image deployment/${K8S_DEPLOYMENT} oetzi=${IMAGE_NAME}:${CI_COMMIT_SHA} --namespace=${K8S_NAMESPACE}
before_script
:
-
"
#==[
install
kubectl
]=================="
be-prd-deploy-job
:
-
wget https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl
extends
:
.be-deploy-job
# NOTE: version is too ald and don't have sha256 available
environment
:
#- wget https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256
name
:
production/backend
# - echo "$(<kubectl.sha256) kubectl" | sha256sum --check
deployment_tier
:
production
-
mv kubectl /usr/bin/ && chmod +x /usr/bin/kubectl
url
:
https://kommul.eurac.edu/oetzi
-
"
#==[
configure
kubectl
]================"
variables
:
-
kubectl config set-cluster "k8sproduction" --server="$KUBE_URL" --certificate-authority="$KUBE_CA_PEM_FILE"
K8S_NAMESPACE
:
kommul
-
kubectl config set-credentials "gitlab-deploy" --token=$K8S_PRODUCTION_TOKEN
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
-
kubectl config set-context "$CI_PROJECT_ID" --cluster="k8sproduction" --user="gitlab-deploy" --namespace="$K8S_NAMESPACE"
only
:
-
kubectl config use-context "$CI_PROJECT_ID"
-
tags
script
:
-
kubectl set image deployment/$K8S_DEPLOYMENT oetzi=${IMAGE_NAME}:${CI_COMMIT_SHA}
be-stg-deploy-job
:
extends
:
.be-deploy-job
be-prd-deploy-job
:
environment
:
extends
:
.be-deploy-job
name
:
staging/backend
environment
:
deployment_tier
:
staging
name
:
production/backend
url
:
https://kommul-dev.eurac.edu/oetzi
deployment_tier
:
production
variables
:
url
:
https://kommul.eurac.edu/oetzi
K8S_NAMESPACE
:
kommul-dev
variables
:
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
K8S_NAMESPACE
:
kommul
only
:
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
-
development
only
:
-
tags
#==[ Frontend build ]===========================================================
be-stg-deploy-job
:
fe-build-job
:
extends
:
.be-deploy-job
image
:
node:16-alpine
environment
:
stage
:
build
name
:
staging/backend
tags
:
deployment_tier
:
staging
-
commul
url
:
https://kommul-dev.eurac.edu/oetzi
cache
:
variables
:
-
key
:
K8S_NAMESPACE
:
kommul-dev
files
:
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
-
frontend/package-lock.json
only
:
paths
:
-
development
-
frontend/node_modules
script
:
#==[ Frontend build ]===========================================================
-
cd frontend
-
npm install
fe-build-job
:
-
npm run build
image
:
node:16-alpine
artifacts
:
stage
:
build
paths
:
tags
:
-
frontend/dist/
-
commul
# TODO: set expiration in docker registry too
cache
:
expire_in
:
1 week
-
key
:
only
:
files
:
-
tags
-
frontend/package-lock.json
-
development
paths
:
-
frontend/node_modules
#==[ Frontend deployment ]======================================================
script
:
-
cd frontend
.fe-deploy-job
:
-
npm install
image
:
alpine:latest
-
npm run build
stage
:
deploy
artifacts
:
needs
:
paths
:
-
job
:
fe-build-job
-
frontend/dist/
artifacts
:
true
# TODO: set expiration in docker registry too
tags
:
expire_in
:
1 week
-
commul
only
:
before_script
:
-
tags
-
./ci/install-butler-on-alpine.sh
-
development
script
:
-
>
#==[ Frontend deployment ]======================================================
butler push
frontend/dist
.fe-deploy-job
:
eurac/$GAME_NAME:html5
image
:
alpine:latest
--userversion ${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
stage
:
deploy
needs
:
fe-prd-deploy-job
:
-
job
:
fe-build-job
extends
:
.fe-deploy-job
artifacts
:
true
environment
:
tags
:
name
:
production/frontend
-
commul
deployment_tier
:
production
before_script
:
url
:
https://eurac.itch.io/oetzi
-
./ci/install-butler-on-alpine.sh
variables
:
script
:
GAME_NAME
:
oetzi
-
>
only
:
butler push
-
tags
frontend/dist
eurac/$GAME_NAME:html5
fe-stg-deploy-job
:
--userversion ${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
extends
:
.fe-deploy-job
environment
:
fe-prd-deploy-job
:
name
:
staging/frontend
extends
:
.fe-deploy-job
deployment_tier
:
staging
environment
:
url
:
https://eurac.itch.io/oetzi-staging
name
:
production/frontend
variables
:
deployment_tier
:
production
GAME_NAME
:
oetzi-staging
url
:
https://eurac.itch.io/oetzi
only
:
variables
:
-
development
GAME_NAME
:
oetzi
only
:
-
tags
fe-stg-deploy-job
:
extends
:
.fe-deploy-job
environment
:
name
:
staging/frontend
deployment_tier
:
staging
url
:
https://eurac.itch.io/oetzi-staging
variables
:
GAME_NAME
:
oetzi-staging
only
:
-
development
This diff is collapsed.
Click to expand it.
ci/install-kubectl-on-alpine.sh
0 → 100755
+
38
−
0
View file @
244ccad1
#!/usr/bin/env sh
set
-e
# exit of first error
#set -o xtrace # trace commands
echo
"Installing kubectl..."
KUBECTL_VERSION
=
v1.8.10
KUBECTL_URL
=
https://storage.googleapis.com/kubernetes-release/release/
$KUBECTL_VERSION
/bin/linux/amd64/kubectl
wget
$KUBECTL_URL
# NOTE: version is too ald and doesn't have sha256 available
# wget https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256
# echo "$(<kubectl.sha256) kubectl" | sha256sum --check
mv
kubectl /usr/bin/
chmod
+x /usr/bin/kubectl
echo
"Configuring kubectl..."
K8S_USER
=
gitlab-deploy
K8S_CLUSTER
=
k8sproduction
kubectl config
\
set-cluster
"
$K8S_CLUSTER
"
\
--server
=
"
$KUBE_URL
"
\
--certificate-authority
=
"
$KUBE_CA_PEM_FILE
"
kubectl config
\
set-credentials
"
$K8S_USER
"
\
--token
=
"
$K8S_PRODUCTION_TOKEN
"
kubectl config
\
set-context
"
$CI_PROJECT_ID
"
\
--cluster
=
"
$K8S_CLUSTER
"
\
--user
=
"
$K8S_USER
"
kubectl config
\
use-context
"
$CI_PROJECT_ID
"
This diff is collapsed.
Click to expand it.
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