diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..60dbd1e --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,28 @@ +steps: + build: + image: plugins/kaniko + settings: + repo: gitea.hottis.de/wn/snmp-mqtt + registry: + from_secret: container_registry + tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG} + username: + from_secret: container_registry_username + password: + from_secret: container_registry_password + dockerfile: Dockerfile + when: + - event: [push, tag] + + deploy: + image: portainer/kubectl-shell:latest + secrets: + - source: kube_config + target: KUBE_CONFIG_CONTENT + commands: + - export IMAGE_TAG=$CI_COMMIT_TAG + - printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig + - export KUBECONFIG=/tmp/kubeconfig + - ./deployment/deploy.sh + when: + - event: tag diff --git a/Dockerfile b/Dockerfile index fc270b8..3bc7860 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,18 @@ -FROM jupyter/scipy-notebook:latest +FROM quay.io/jupyter/scipy-notebook:2024-01-23 LABEL Maintainer="Wolfgang Hottgenroth " -LABEL ImageName="registry.gitlab.com/wolutator/registry.gitlab.com/wolutator/" ENV PASSWORD "" +USER root +RUN \ + apt update && \ + apt install -y postgresql-client-common libpq-dev + +USER $NB_USER RUN \ conda update -y -n base conda && \ - pip install influxdb && \ - pip install pymongo && \ + pip install psycopg && \ conda install -y pandas-datareader && \ fix-permissions $CONDA_DIR && \ fix-permissions /home/$NB_USER diff --git a/deployment/deploy-yml.tmpl b/deployment/deploy-yml.tmpl new file mode 100644 index 0000000..9d83f25 --- /dev/null +++ b/deployment/deploy-yml.tmpl @@ -0,0 +1,59 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jupyter + labels: + app: jupyter +spec: + replicas: 1 + selector: + matchLabels: + app: jupyter + template: + metadata: + labels: + app: jupyter + spec: + containers: + - name: jupyter + image: %IMAGE% + ports: + - containerPort: 8888 + protocol: TCP +--- +apiVersion: v1 +kind: Service +metadata: + name: jupyter +spec: + type: ClusterIP + selector: + app: jupyter + ports: + - name: http + targetPort: 8888 + port: 80 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: jupyter + annotations: + cert-manager.io/cluster-issuer: letsencrypt-staging-http +spec: + tls: + - hosts: + - jupyter.hottis.de + secretName: jupyter-cert + rules: + - host: jupyter.hottis.de + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: jupyter + port: + number: 80 + diff --git a/deployment/deploy.sh b/deployment/deploy.sh new file mode 100755 index 0000000..d0d1bdd --- /dev/null +++ b/deployment/deploy.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +if [ "$IMAGE_TAG" == "" ]; then + echo "Make sure IMAGE_TAG is set" + exit 1 +fi + + +IMAGE_NAME=gitea.hottis.de/wn/jupyter-scipy-database-extension +NAMESPACE=jupyter +DEPLOYMENT_DIR=$PWD/deployment + +pushd $DEPLOYMENT_DIR > /dev/null + +kubectl create namespace $NAMESPACE \ + --dry-run=client \ + -o yaml | \ + kubectl -f - apply + + +cat $DEPLOYMENT_DIR/deploy-yml.tmpl | \ + sed -e 's,%IMAGE%,'$IMAGE_NAME':'$IMAGE_TAG','g | \ + kubectl apply -f - -n $NAMESPACE + +popd > /dev/null +