Merge branch 'ci-update' into 'master'
Updated CI. See merge request telegram-bots/lenochka!1
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
.vscode/
|
||||
.idea/
|
||||
.gen.env
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
@ -1,70 +1,78 @@
|
||||
stages:
|
||||
- tools
|
||||
- test
|
||||
- cleanup_tests
|
||||
- build
|
||||
- deploy
|
||||
|
||||
build_test:
|
||||
stage: tools
|
||||
variables:
|
||||
APP_VERSION: ${CI_COMMIT_REF_SLUG}
|
||||
|
||||
.test-template:
|
||||
image: python:3.9-buster
|
||||
stage: test
|
||||
tags:
|
||||
- bots-deployer
|
||||
script:
|
||||
- make build-test
|
||||
- kube
|
||||
except:
|
||||
- tags
|
||||
before_script:
|
||||
- echo "${DOCKER_REGISTRY}"
|
||||
- pip install poetry==1.1.6
|
||||
- poetry config virtualenvs.create false
|
||||
- poetry install
|
||||
|
||||
flake8:
|
||||
stage: test
|
||||
tags:
|
||||
- bots-deployer
|
||||
extends:
|
||||
- .test-template
|
||||
script:
|
||||
- make flake8
|
||||
- flake8 --count .
|
||||
|
||||
pytest:
|
||||
stage: test
|
||||
tags:
|
||||
- bots-deployer
|
||||
extends:
|
||||
- .test-template
|
||||
script:
|
||||
- make pytest
|
||||
- pytest -vv
|
||||
|
||||
black:
|
||||
stage: test
|
||||
tags:
|
||||
- bots-deployer
|
||||
extends:
|
||||
- .test-template
|
||||
script:
|
||||
- make black
|
||||
- black --check .
|
||||
|
||||
mypy:
|
||||
stage: test
|
||||
tags:
|
||||
- bots-deployer
|
||||
extends:
|
||||
- .test-template
|
||||
script:
|
||||
- make mypy
|
||||
- mypy .
|
||||
|
||||
cleanup_tests:
|
||||
stage: cleanup_tests
|
||||
tags:
|
||||
- bots-deployer
|
||||
when: always
|
||||
script:
|
||||
- make clear-test
|
||||
|
||||
build:
|
||||
image-builder:
|
||||
stage: build
|
||||
only:
|
||||
- master
|
||||
- tags
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
||||
entrypoint: [ "" ]
|
||||
tags:
|
||||
- bots-deployer
|
||||
- kube
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- make build push
|
||||
- mkdir -p /kaniko/.docker
|
||||
- echo "{\"auths\":{\"$DOCKER_REGISTRY\":{\"username\":\"$DOCKER_USER\",\"password\":\"$DOCKER_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||
- /kaniko/executor --context .
|
||||
--dockerfile deploy/Dockerfile
|
||||
--destination "$IMAGE_NAME:$APP_VERSION"
|
||||
--force
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
only:
|
||||
- master
|
||||
- tags
|
||||
when: manual
|
||||
image: dtzar/helm-kubectl:3.6.3
|
||||
tags:
|
||||
- bots-deployer
|
||||
- kube
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- make deploy-prod
|
||||
- export KUBECONFIG=$KUBE_CONF
|
||||
- env | grep "^LENOCHKA_" > .deploy-env
|
||||
- kubectl delete configmap --namespace "$NAMESPACE" "$ENVCONF" || true
|
||||
- kubectl create configmap --namespace "$NAMESPACE" "$ENVCONF" --from-env-file=.deploy-env
|
||||
- envsubst < "$HELM_VALUES" > deploy-values.yml
|
||||
- helm upgrade lenocka deploy/charts/lenocka/ -f deploy-values.yml --namespace "$NAMESPACE"
|
@ -1,16 +1,11 @@
|
||||
FROM python:3.9-alpine3.13
|
||||
FROM python:3.9.6-slim-buster
|
||||
|
||||
RUN adduser --disabled-password lenochka
|
||||
|
||||
RUN apk add --no-cache curl gcc musl-dev
|
||||
|
||||
ENV POETRY_VERSION 1.1.6
|
||||
RUN useradd -m lenochka
|
||||
|
||||
USER lenochka
|
||||
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
|
||||
RUN pip install poetry==1.1.6
|
||||
|
||||
ENV PATH="${PATH}:/home/lenochka/.poetry/bin:/home/lenochka/.local/bin"
|
||||
RUN source "/home/lenochka/.poetry/env"
|
||||
|
||||
# Installing requirements
|
||||
RUN poetry config virtualenvs.create false
|
||||
@ -31,7 +26,6 @@ USER root
|
||||
RUN rm -rf /home/lenochka/app/src
|
||||
RUN chown -R lenochka /home/lenochka
|
||||
RUN chmod -R 700 /home/lenochka
|
||||
RUN apk del curl gcc musl-dev
|
||||
USER lenochka
|
||||
|
||||
CMD "lenochka_wake_up"
|
23
deploy/charts/lenocka/.helmignore
Normal file
23
deploy/charts/lenocka/.helmignore
Normal file
@ -0,0 +1,23 @@
|
||||
# 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/
|
8
deploy/charts/lenocka/Chart.yaml
Normal file
8
deploy/charts/lenocka/Chart.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
apiVersion: v2
|
||||
name: lenocka
|
||||
description: A Helm chart for Kubernetes
|
||||
|
||||
type: application
|
||||
|
||||
version: "0.1.0"
|
||||
appVersion: "0.1.0"
|
0
deploy/charts/lenocka/templates/NOTES.txt
Normal file
0
deploy/charts/lenocka/templates/NOTES.txt
Normal file
62
deploy/charts/lenocka/templates/_helpers.tpl
Normal file
62
deploy/charts/lenocka/templates/_helpers.tpl
Normal file
@ -0,0 +1,62 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "lenocka.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 "lenocka.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 "lenocka.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "lenocka.labels" -}}
|
||||
helm.sh/chart: {{ include "lenocka.chart" . }}
|
||||
{{ include "lenocka.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "lenocka.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "lenocka.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "lenocka.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "lenocka.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
47
deploy/charts/lenocka/templates/deployment.yaml
Normal file
47
deploy/charts/lenocka/templates/deployment.yaml
Normal file
@ -0,0 +1,47 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "lenocka.fullname" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "lenocka.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "lenocka.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "lenocka.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: Always
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: {{ .Values.image.envConfig }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
11
deploy/charts/lenocka/values.yaml
Normal file
11
deploy/charts/lenocka/values.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: repo
|
||||
tag: tag
|
||||
envConfig: config
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
@ -1,14 +0,0 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
test_lenochka:
|
||||
container_name: the_test_lenochka
|
||||
build:
|
||||
dockerfile: ./deploy/dockerfiles/test.Dockerfile
|
||||
context: .
|
||||
networks:
|
||||
- lenochka_test_network
|
||||
|
||||
networks:
|
||||
lenochka_test_network:
|
||||
name: lenochka_test_network
|
@ -1,11 +0,0 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
lenochka:
|
||||
container_name: the_lenochka
|
||||
build:
|
||||
dockerfile: ./deploy/dockerfiles/Dockerfile
|
||||
context: .
|
||||
image: docker.le-memese.com/bots/lenochka-bot:${CI_COMMIT_REF_SLUG:-latest}
|
||||
env_file:
|
||||
- .gen.env
|
@ -1,17 +0,0 @@
|
||||
FROM python:3.9-alpine3.13
|
||||
|
||||
RUN apk add --no-cache curl gcc musl-dev
|
||||
ENV POETRY_VERSION 1.1.6
|
||||
|
||||
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
|
||||
|
||||
ENV PATH="${PATH}:/root/.local/bin:/root/.poetry/bin"
|
||||
RUN source "/root/.poetry/env"
|
||||
|
||||
# Installing requirements
|
||||
RUN poetry config virtualenvs.create false
|
||||
|
||||
COPY . /app/
|
||||
WORKDIR /app/
|
||||
|
||||
RUN poetry install
|
Reference in New Issue
Block a user