add gitlab ci

This commit is contained in:
ducoterra
2020-10-28 10:14:36 -04:00
parent 68bcbdf7fd
commit c3402af3f0
14 changed files with 254 additions and 2 deletions

3
.gitignore vendored
View File

@@ -1 +1,2 @@
venv/
venv/
site/

34
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,34 @@
variables:
CI_PROJECT_DIR: "."
CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/python-docs-2020
DEPLOY: pythondocs2020
stages:
- build
- deploy
build:
only:
variables:
- $CI_COMMIT_TAG
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
deploy:
stage: deploy
only:
variables:
- $CI_COMMIT_TAG
image:
name: debian:10
entrypoint: [""]
script:
- apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null
- curl -o /usr/bin/kubectl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
- chmod +x /usr/bin/kubectl
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- helm upgrade --install $DEPLOY ./helm --set image=$CI_REGISTRY_IMAGE --set tag=$CI_COMMIT_TAG

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM python:3.9.0 as BUILD
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY mkdocs.yml .
COPY docs docs
RUN mkdocs build
FROM nginx:latest
COPY --from=BUILD /site/ /usr/share/nginx/html/

8
docker-compose.yaml Normal file
View File

@@ -0,0 +1,8 @@
version: '3'
services:
docs:
image: hub.ducoterra.net/ducoterra/python-docs-2020:latest
build: .
ports:
- 8080:80

View File

@@ -4,7 +4,9 @@ When you start programming half the battle is getting your bearings. Suddenly it
Fortunately we can do some things to make your life easier. We can install an IDE: a program that lets you visualize your files and folders and quickly switch between them. We can install a version control system that will let you "snapshot" your code and save it to the cloud so you never lose it. We can organize our project to be repeatable, and more importantly, unloseable.
## I have a Windows PC (or skip to [I have a Mac](#i-have-a-mac))
## I have a Windows PC
(or skip to [I have a Mac](#i-have-a-mac))
### Install Git

6
docs/index.md Normal file
View File

@@ -0,0 +1,6 @@
# Welcome to Project Oriented Python 2020
## Days
Day 0: Installation requirements
Day 1: Python basics

23
helm/.helmignore Normal file
View 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/

23
helm/Chart.yaml Normal file
View File

@@ -0,0 +1,23 @@
apiVersion: v2
name: helm
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.1.0
# 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.
appVersion: 1.16.0

View File

@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
spec:
containers:
- image: {{ required "A valid .Values.image entry required!" .Values.image }}:{{ required "A valid .Values.tag entry required!" .Values.tag }}
name: {{ .Release.Name }}
ports:
- containerPort: 80
resources:
limits:
memory: "500Mi"
cpu: "250m"
requests:
memory: "1Mi"
cpu: "100m"

View File

@@ -0,0 +1,78 @@
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ .Release.Name }}-internal-tls
annotations:
kubernetes.io/ingress.class: traefik-internal
spec:
entryPoints:
- websecure
tls:
certResolver: myresolver
domains:
- main: "*.ducoterra.net"
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ .Release.Name }}-internal-web
annotations:
kubernetes.io/ingress.class: traefik-internal
spec:
entryPoints:
- web
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
middlewares:
- name: httpsredirect
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ .Release.Name }}-external-tls
annotations:
kubernetes.io/ingress.class: traefik-external
spec:
entryPoints:
- websecure
tls:
certResolver: myresolver
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ .Release.Name }}-external-web
annotations:
kubernetes.io/ingress.class: traefik-external
spec:
entryPoints:
- web
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
middlewares:
- name: httpsredirect

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: {{ .Release.Name }}
name: {{ .Release.Name }}
spec:
ports:
- port: {{ .Values.port }}
protocol: TCP
name: {{ .Release.Name }}-web
targetPort: {{ .Values.port }}
selector:
app: {{ .Release.Name }} # This selects the pod(s) that match the selector
type: ClusterIP

1
helm/values.yaml Normal file
View File

@@ -0,0 +1 @@
port: 80

7
mkdocs.yml Normal file
View File

@@ -0,0 +1,7 @@
site_name: Python Class 2020
nav:
- Home: index.md
- Day 0: day0.md
- Day 1: day1.md
theme:
name: material

19
requirements.txt Normal file
View File

@@ -0,0 +1,19 @@
click==7.1.2
future==0.18.2
Jinja2==2.11.2
joblib==0.17.0
livereload==2.6.3
lunr==0.5.8
Markdown==3.3.3
MarkupSafe==1.1.1
mkdocs==1.1.2
mkdocs-material==6.1.0
mkdocs-material-extensions==1.0.1
nltk==3.5
Pygments==2.7.2
pymdown-extensions==8.0.1
PyYAML==5.3.1
regex==2020.10.23
six==1.15.0
tornado==6.0.4
tqdm==4.51.0