Unverified Commit fa682d61 authored by torgiren's avatar torgiren
Browse files

init

Signed-off-by: torgiren's avatarMarcin Fabrykowski <git@fabrykowski.pl>
parent 239418dc
No related merge requests found
Pipeline #2570 passed with stages
in 2 minutes and 29 seconds
Showing with 312 additions and 0 deletions
+312 -0
stages:
- prepare
- build
- push
- push tagged
- deploy branch
- cleanup
- upload
get version:
stage: prepare
image: bitnami/git
script:
- mkdir output
- "git describe --tags > output/version.txt"
artifacts:
paths:
- output/version.txt
build:
stage: build
image: quay.io/podman/stable
script:
- echo -n $CI_REGISTRY_PASSWORD | podman login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- podman build --tag $CI_REGISTRY_IMAGE:dev .
- podman push $CI_REGISTRY_IMAGE:dev
- "podman tag $CI_REGISTRY_IMAGE:dev $CI_REGISTRY_IMAGE:$(cat output/version.txt)"
- "podman push $CI_REGISTRY_IMAGE:$(cat output/version.txt)"
push image:
variables:
GIT_STRATEGY: none
image: quay.io/podman/stable
stage: push
only:
- master
- tags
script:
- echo -n $CI_REGISTRY_PASSWORD | podman login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- podman pull $CI_REGISTRY_IMAGE:dev
- podman tag $CI_REGISTRY_IMAGE:dev $CI_REGISTRY_IMAGE:latest
- podman push $CI_REGISTRY_IMAGE:latest
deploy branch:
stage: deploy branch
image:
name: alpine/helm
environment:
name: dev/$CI_COMMIT_REF_SLUG
on_stop: delete_app
url: https://$KUBE_NAMESPACE.ci.exphost.pl
before_script:
- apk add --no-cache ca-certificates git curl
- curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl
- chmod +x /usr/local/bin/kubectl
script:
- echo "CI_ENVIRONMENT_SLUG $CI_ENVIRONMENT_SLUG"
- echo "CI_ENVIRONMENT_SLUG $CI_ENVIRONMENT_SLUG"
- echo "KUBE_NAMESPACE $KUBE_NAMESPACE"
- export VERSION=$(git describe --tags)
- export APPVERSION=$VERSION
- 'sed -i "s/^version\: 0.0.0-placeholder$/version\: $VERSION/" chart/Chart.yaml'
- 'sed -i "s/^appVersion\: 0.0.0-placeholder$/appVersion\: $APPVERSION/" chart/Chart.yaml'
#- sed -i "s/__DOMAIN__/${KUBE_NAMESPACE}.ci.exphost.pl/" gitlab-ci-values-dex.yml
#- sed -i "s/__DOMAIN__/${KUBE_NAMESPACE}.ci.exphost.pl/" gitlab-ci-values-domainsservice.yml
#- sed -i "s/__DOMAIN__/${KUBE_NAMESPACE}.ci.exphost.pl/" gitlab-ci-values.yml
- >
helm upgrade -n $KUBE_NAMESPACE -i test-frontend chart -f gitlab-ci-values.yml
--set podAnnotations."app\.gitlab\.com/app"=$CI_PROJECT_PATH_SLUG
--set podAnnotations."app\.gitlab\.com/env"=$CI_ENVIRONMENT_SLUG
--set global.domain=${KUBE_NAMESPACE}.ci.exphost.pl
--wait --wait-for-jobs
- kubectl -n $KUBE_NAMESPACE rollout restart deployment test-frontend
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH
delete_app:
stage: cleanup
image:
name: alpine/helm
before_script:
- apk add --no-cache ca-certificates git curl
- curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl
- chmod +x /usr/local/bin/kubectl
script:
- helm uninstall -n $KUBE_NAMESPACE test-frontend --wait
- kubectl -n $KUBE_NAMESPACE delete pvc --all
variables:
GIT_STRATEGY: none
environment:
name: dev/$CI_COMMIT_REF_SLUG
action: stop
needs:
- deploy branch
when: manual
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_BRANCH
FROM python:3
COPY requirements.txt /requirements.txt
RUN pip install -r requirements.txt
COPY app /app
WORKDIR /app
CMD gunicorn main:app -b 0.0.0.0 -w 5
from flask import Flask, request
app = Flask(__name__)
@app.route("/"):
def process():
return "Home page"
if __name__ == "__main__":
app.run()
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
apiVersion: v2
name: frontend
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.0-placeholder
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 0.0.0-placeholder
{{/*
Expand the name of the chart.
*/}}
{{- define "chart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "chart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "chart.labels" -}}
helm.sh/chart: {{ include "chart.chart" . }}
{{ include "chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "chart.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "chart.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8000
protocol: TCP
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
tls:
- hosts:
- {{ .Values.global.domain }}
secretName: {{ .Values.global.domain }}-tls
rules:
- host: {{ .Values.global.domain }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: {{ include "chart.fullname" . }}
port:
number: 8000
apiVersion: v1
kind: Service
metadata:
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
ports:
- port: 8000
targetPort: http
protocol: TCP
name: http
selector:
{{- include "chart.selectorLabels" . | nindent 4 }}
global:
domain: example.com
replicaCount: 1
image:
repository: registry.gitlab.exphost.pl/torgiren/jesien-2022-frontend
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
click==8.1.3
Flask==2.2.2
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
python-slugify==6.1.2
text-unidecode==1.3
Werkzeug==2.2.2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment