diff --git a/docker/demo/Dockerfile b/docker/demo/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac3be4ba65032ff7a101da9c0ede0102e04540fa --- /dev/null +++ b/docker/demo/Dockerfile @@ -0,0 +1,30 @@ +FROM python:3.8-slim-bookworm + +# Install apt dependencies +RUN apt-get update && \ + apt-get install -y git graphviz sqlite3 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Install Autosubmit +ARG AUTOSUBMIT_VERSION=4.0.105 +ARG AUTOSUBMIT_API_VERSION=4.0.0b8 + +RUN pip3 install \ + autosubmit==${AUTOSUBMIT_VERSION} \ + autosubmit-api==${AUTOSUBMIT_API_VERSION} \ + jupyterlab + +# Set the environment variables +ENV PROTECTION_LEVEL=NONE + +# Install Autosubmit +RUN autosubmit configure &&\ + autosubmit install + +# Copy entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Set the entrypoint +ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/demo/README.md b/docker/demo/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b86253b06818a450defa074baa2786d3adb6133c --- /dev/null +++ b/docker/demo/README.md @@ -0,0 +1,55 @@ + +## Prepare Minikube + +### Build the docker images inside minikube + +Build the images inside Minikube + +```bash +eval $(minikube docker-env) + +docker build -t as-demo:latest ~/projects/autosubmit/docker/demo +docker build --build-arg "AUTOSUBMIT_API_SOURCE=/api" --build-arg="PUBLIC_URL=/gui"\ + -t as-gui-demo:latest ~/projects/autosubmitreact-update/docker +``` + +The script above use the default names of the images. You can change and set them in the `values.yaml` as you wish. + +### Install Nginx Ingress Controller + +Install nginx Ingress Controller https://kubernetes.github.io/ingress-nginx/deploy/ + +```bash +helm upgrade --install ingress-nginx ingress-nginx \ + --repo https://kubernetes.github.io/ingress-nginx \ + --namespace ingress-nginx --create-namespace +``` + +Enable Ingress for testing + +```bash +minikube addons enable ingress +``` + +## Install using helm + +Install helm + +```bash +helm install test-demo . +``` + + +Clean up helm + +```bash +helm uninstall test-demo +``` + +## Test locally + +Forward nginx ingress controller port `80` to `localhost:8080`: + +```bash +kubectl port-forward --namespace=ingress-nginx service/ingress-nginx-controller 8080:80 +``` \ No newline at end of file diff --git a/docker/demo/entrypoint.sh b/docker/demo/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..b261542176270ad0c52f1092e1233df146a87161 --- /dev/null +++ b/docker/demo/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Run jupyter lab as daemon +jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.base_url=/jupyterlab & + +# Run the command passed by docker run +autosubmit_api start -b 0.0.0.0:8000 diff --git a/docker/demo/helm/.helmignore b/docker/demo/helm/.helmignore new file mode 100644 index 0000000000000000000000000000000000000000..0e8a0eb36f4ca2c939201c0d54b5d82a1ea34778 --- /dev/null +++ b/docker/demo/helm/.helmignore @@ -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/ diff --git a/docker/demo/helm/Chart.yaml b/docker/demo/helm/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7875694c6f4f944a463c5fb4f3ef5ba29d3580c2 --- /dev/null +++ b/docker/demo/helm/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: autosubmit-demo +description: A Helm chart for trying Autosubmit tools + +# 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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/docker/demo/helm/templates/deployment.yaml b/docker/demo/helm/templates/deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2482ccd9f89d0f08d74239022bc94b4be56f789b --- /dev/null +++ b/docker/demo/helm/templates/deployment.yaml @@ -0,0 +1,32 @@ +# Add deployment and service +apiVersion: apps/v1 +kind: Deployment +metadata: + name: autosubmit-deployment + labels: + app: autosubmit-demo +spec: + replicas: 1 + selector: + matchLabels: + app: autosubmit-demo + template: + metadata: + labels: + app: autosubmit-demo + spec: + containers: + # Main Autosubmit docker image with exposed ports 8888 and 8000 + - name: autosubmit-container + image: {{ .Values.images.autosubmitDemo.image }} + imagePullPolicy: {{ .Values.images.autosubmitDemo.imagePullPolicy }} + ports: + - containerPort: 8888 + - containerPort: 8000 + # GUI docker image with exposed port 3000 + - name: autosubmit-gui-container + image: {{ .Values.images.autosubmitDemoGUI.image }} + imagePullPolicy: {{ .Values.images.autosubmitDemoGUI.imagePullPolicy }} + ports: + - containerPort: 8080 + diff --git a/docker/demo/helm/templates/ingress.yaml b/docker/demo/helm/templates/ingress.yaml new file mode 100644 index 0000000000000000000000000000000000000000..733096debb94ce7b6691a2217dfa2b715ce8afa9 --- /dev/null +++ b/docker/demo/helm/templates/ingress.yaml @@ -0,0 +1,48 @@ +# Rewrite ingress +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: autosubmit-ingress + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/rewrite-target: /$2 +spec: + ingressClassName: nginx + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - pathType: ImplementationSpecific + path: "/api(/|$)(.*)" + backend: + service: + name: autosubmit-demo-service + port: + number: 8000 +--- +# Prefix ingress +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: autosubmit-ingress-gui +spec: + ingressClassName: nginx + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - pathType: Prefix + path: "/jupyterlab" + backend: + service: + name: autosubmit-demo-service + port: + number: 8888 + - pathType: Prefix + path: "/gui" + backend: + service: + name: autosubmit-demo-service + port: + number: 8080 + \ No newline at end of file diff --git a/docker/demo/helm/templates/service.yaml b/docker/demo/helm/templates/service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1432a0d3278de5d4ec4491e034cf7988988504e9 --- /dev/null +++ b/docker/demo/helm/templates/service.yaml @@ -0,0 +1,23 @@ +# Add service +apiVersion: v1 +kind: Service +metadata: + name: autosubmit-demo-service + labels: + app: autosubmit-demo +spec: + selector: + app: autosubmit-demo + ports: + - name: jupyterlab-port + protocol: TCP + port: 8888 + targetPort: 8888 + - name: api-port + protocol: TCP + port: 8000 + targetPort: 8000 + - name: gui-port + protocol: TCP + port: 8080 + targetPort: 8080 diff --git a/docker/demo/helm/values.yaml b/docker/demo/helm/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5322d4e3a00bb6343ef205a8e2ea1b677c94005f --- /dev/null +++ b/docker/demo/helm/values.yaml @@ -0,0 +1,10 @@ +images: + autosubmitDemo: + image: as-demo + imagePullPolicy: Never + autosubmitDemoGUI: + image: as-gui-demo + imagePullPolicy: Never + +ingress: + host: localhost \ No newline at end of file