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
:
DOCKER_TLS_CERTDIR
:
"
"
# HACK: see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
DOCKER_IMAGE
:
"
docker:20.10.12"
stages
:
-
build
-
deploy
#==[ Backend build ]============================================================
# TODO: cache docker layers
# TODO: build ts
be-build-job
:
image
:
$DOCKER_IMAGE
stage
:
build
tags
:
-
commul
services
:
-
docker:dind
variables
:
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
before_script
:
-
docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN https://$CI_REGISTRY
script
:
-
>
docker build
--rm --no-cache
--target production
--tag=$IMAGE_NAME:${CI_COMMIT_SHA}
--tag=$IMAGE_NAME:${CI_COMMIT_REF_NAME}
--tag=$IMAGE_NAME:${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
backend
-
docker image push --all-tags $IMAGE_NAME
only
:
-
tags
-
development
#==[ Backend deployment ]=======================================================
.be-deploy-job
:
image
:
alpine:latest
# image: $DOCKER_IMAGE
stage
:
deploy
needs
:
-
job
:
be-build-job
artifacts
:
false
# TODO: maybe we can get the build image as an artifact?
tags
:
-
commul
# services:
# - docker:dind
variables
:
KUBECTL_VERSION
:
v1.8.10
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
before_script
:
-
"
#==[
install
kubectl
]=================="
-
wget https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl
# NOTE: version is too ald and don'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
-
"
#==[
configure
kubectl
]================"
-
kubectl config set-cluster "k8sproduction" --server="$KUBE_URL" --certificate-authority="$KUBE_CA_PEM_FILE"
-
kubectl config set-credentials "gitlab-deploy" --token=$K8S_PRODUCTION_TOKEN
-
kubectl config set-context "$CI_PROJECT_ID" --cluster="k8sproduction" --user="gitlab-deploy" --namespace="$K8S_NAMESPACE"
-
kubectl config use-context "$CI_PROJECT_ID"
script
:
-
kubectl set image deployment/$K8S_DEPLOYMENT oetzi=${IMAGE_NAME}:${CI_COMMIT_SHA}
be-prd-deploy-job
:
extends
:
.be-deploy-job
environment
:
name
:
production/backend
deployment_tier
:
production
url
:
https://kommul.eurac.edu/oetzi
variables
:
K8S_NAMESPACE
:
kommul
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
only
:
-
tags
be-stg-deploy-job
:
extends
:
.be-deploy-job
environment
:
name
:
staging/backend
deployment_tier
:
staging
url
:
https://kommul-dev.eurac.edu/oetzi
variables
:
K8S_NAMESPACE
:
kommul-dev
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
only
:
-
development
#==[ Frontend build ]===========================================================
fe-build-job
:
image
:
node:16-alpine
stage
:
build
tags
:
-
commul
cache
:
-
key
:
files
:
-
frontend/package-lock.json
paths
:
-
frontend/node_modules
script
:
-
cd frontend
-
npm install
-
npm run build
artifacts
:
paths
:
-
frontend/dist/
# TODO: set expiration in docker registry too
expire_in
:
1 week
only
:
-
tags
-
development
#==[ Frontend deployment ]======================================================
.fe-deploy-job
:
image
:
alpine:latest
stage
:
deploy
needs
:
-
job
:
fe-build-job
artifacts
:
true
tags
:
-
commul
before_script
:
-
./ci/install-butler-on-alpine.sh
script
:
-
>
butler push
frontend/dist
eurac/$GAME_NAME:html5
--userversion ${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
fe-prd-deploy-job
:
extends
:
.fe-deploy-job
environment
:
name
:
production/frontend
deployment_tier
:
production
url
:
https://eurac.itch.io/oetzi
variables
:
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
variables
:
DOCKER_TLS_CERTDIR
:
"
"
# HACK: see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
DOCKER_IMAGE
:
"
docker:20.10.12"
stages
:
-
build
-
deploy
#==[ Backend build ]============================================================
# TODO: cache docker layers
# TODO: build ts
be-build-job
:
image
:
$DOCKER_IMAGE
stage
:
build
tags
:
-
commul
services
:
-
docker:dind
variables
:
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
before_script
:
-
docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN https://$CI_REGISTRY
script
:
-
>
docker build
--rm --no-cache
--target production
--tag=$IMAGE_NAME:${CI_COMMIT_SHA}
--tag=$IMAGE_NAME:${CI_COMMIT_REF_NAME}
--tag=$IMAGE_NAME:${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
backend
-
docker image push --all-tags $IMAGE_NAME
only
:
-
tags
-
development
#==[ Backend deployment ]=======================================================
.be-deploy-job
:
image
:
alpine:latest
stage
:
deploy
needs
:
-
job
:
be-build-job
artifacts
:
false
tags
:
-
commul
variables
:
IMAGE_NAME
:
$CI_REGISTRY_IMAGE/backend
before_script
:
-
./ci/install-kubectl-on-alpine.sh
script
:
-
kubectl set image deployment/${K8S_DEPLOYMENT} oetzi=${IMAGE_NAME}:${CI_COMMIT_SHA} --namespace=${K8S_NAMESPACE}
be-prd-deploy-job
:
extends
:
.be-deploy-job
environment
:
name
:
production/backend
deployment_tier
:
production
url
:
https://kommul.eurac.edu/oetzi
variables
:
K8S_NAMESPACE
:
kommul
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
only
:
-
tags
be-stg-deploy-job
:
extends
:
.be-deploy-job
environment
:
name
:
staging/backend
deployment_tier
:
staging
url
:
https://kommul-dev.eurac.edu/oetzi
variables
:
K8S_NAMESPACE
:
kommul-dev
K8S_DEPLOYMENT
:
oetzi-webserver-deployment
only
:
-
development
#==[ Frontend build ]===========================================================
fe-build-job
:
image
:
node:16-alpine
stage
:
build
tags
:
-
commul
cache
:
-
key
:
files
:
-
frontend/package-lock.json
paths
:
-
frontend/node_modules
script
:
-
cd frontend
-
npm install
-
npm run build
artifacts
:
paths
:
-
frontend/dist/
# TODO: set expiration in docker registry too
expire_in
:
1 week
only
:
-
tags
-
development
#==[ Frontend deployment ]======================================================
.fe-deploy-job
:
image
:
alpine:latest
stage
:
deploy
needs
:
-
job
:
fe-build-job
artifacts
:
true
tags
:
-
commul
before_script
:
-
./ci/install-butler-on-alpine.sh
script
:
-
>
butler push
frontend/dist
eurac/$GAME_NAME:html5
--userversion ${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
fe-prd-deploy-job
:
extends
:
.fe-deploy-job
environment
:
name
:
production/frontend
deployment_tier
:
production
url
:
https://eurac.itch.io/oetzi
variables
:
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