From 0d2989ecb2ad4f6e3dadc363f8ca423f617081c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Schl=C3=A4fli?= Date: Fri, 27 Oct 2023 20:05:58 +0200 Subject: [PATCH 1/4] add initial draft files --- .devcontainer/Dockerfile | 12 +++++++++++ .devcontainer/devcontainer.json | 26 ++++++++++++++++++++++++ .devcontainer/docker-compose.yml | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..f2432aed5e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment if you want to install an additional version of node using nvm +# ARG EXTRA_NODE_VERSION=10 +# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" + +# [Optional] Uncomment if you want to install more global node modules +# RUN su node -c "npm install -g " diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..0401f33974 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node-postgres +{ + "name": "Node.js & PostgreSQL", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "features": { + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // This can be used to network with other containers or with the host. + // "forwardPorts": [3000, 5432], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000000..01c634a116 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + + volumes: + - ../..:/workspaces:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + network_mode: service:db + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + db: + image: docker.io/library/postgres:latest + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: postgres + + # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + +volumes: + postgres-data: From 1b6f1574b57a4b0dfb714ee2cb8f5be5da4ac169 Mon Sep 17 00:00:00 2001 From: Roland Schlaefli Date: Fri, 27 Oct 2023 22:55:58 +0200 Subject: [PATCH 2/4] extensions --- .devcontainer/Dockerfile | 7 +++-- .devcontainer/devcontainer.json | 6 ++-- .devcontainer/docker-compose.yml | 50 +++++++++++++++++++++++++------- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f2432aed5e..d5e3ee56c8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye +FROM mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ @@ -8,5 +8,6 @@ FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye # ARG EXTRA_NODE_VERSION=10 # RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" -# [Optional] Uncomment if you want to install more global node modules -# RUN su node -c "npm install -g " +RUN su node -c "npm install --global pnpm@8" \ + && su node -c "SHELL=bash pnpm setup" \ + && su node -c "pnpm config set store-dir /home/node/.local/share/pnpm/store" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0401f33974..73c9077457 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,10 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node-postgres { - "name": "Node.js & PostgreSQL", + "name": "KlickerUZH Dev Container", "dockerComposeFile": "docker-compose.yml", "service": "app", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "features": { - } // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, @@ -16,7 +14,7 @@ // "forwardPorts": [3000, 5432], // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "yarn install", + "postCreateCommand": "pnpm install" // Configure tool-specific properties. // "customizations": {}, diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 01c634a116..4c1c585366 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -13,23 +13,51 @@ services: command: sleep infinity # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. - network_mode: service:db + network_mode: service:postgres # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. # (Adding the "ports" property to this file will not forward from a Codespace.) - db: - image: docker.io/library/postgres:latest - restart: unless-stopped + reverse_proxy_docker: + image: docker.io/library/traefik:v2.10 + command: + - --api.insecure=true + - --providers.file=true + - --providers.file.filename=/etc/traefik/rules.yaml + - --providers.file.watch=true + - --entrypoints.web.address=:80 + ports: + - 8088:80 + - 8080:8080 volumes: - - postgres-data:/var/lib/postgresql/data + - '../util/traefik/rules_devcontainer.yaml:/etc/traefik/rules.yaml' + + # main database + postgres: + image: docker.io/library/postgres:15 environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - POSTGRES_DB: postgres + POSTGRES_USER: klicker + POSTGRES_PASSWORD: klicker + POSTGRES_DB: klicker + ports: + - 5432:5432 + volumes: + - postgres_data:/var/lib/postgresql/data - # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. - # (Adding the "ports" property to this file will not forward from a Codespace.) + # redis instance to support session execution + redis_exec: + image: docker.io/library/redis:7 + ports: + - 6379:6379 + volumes: + - redis_data:/data + + # redis instance for page caching and rate limiting + redis_cache: + image: docker.io/library/redis:7 + ports: + - 6380:6379 volumes: - postgres-data: + postgres_data: + redis_data: From b8da1ba8228afef59b749f62aedd20fa1b5dbcb8 Mon Sep 17 00:00:00 2001 From: Roland Schlaefli Date: Fri, 27 Oct 2023 23:09:11 +0200 Subject: [PATCH 3/4] add devcontainer rules --- util/traefik/rules_devcontainer.yaml | 79 ++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 util/traefik/rules_devcontainer.yaml diff --git a/util/traefik/rules_devcontainer.yaml b/util/traefik/rules_devcontainer.yaml new file mode 100644 index 0000000000..8cc2590013 --- /dev/null +++ b/util/traefik/rules_devcontainer.yaml @@ -0,0 +1,79 @@ +http: + routers: + api: + rule: "Host(`api.klicker.com`)" + entrypoints: + - "web" + service: "api" + + pwa: + rule: "Host(`pwa.klicker.com`)" + entrypoints: + - "web" + service: "pwa" + + manage: + rule: "Host(`manage.klicker.com`)" + entrypoints: + - "web" + service: "manage" + + control: + rule: "Host(`control.klicker.com`)" + entrypoints: + - "web" + service: "control" + + auth: + rule: "Host(`auth.klicker.com`)" + entrypoints: + - "web" + service: "auth" + + func-responses: + rule: "Host(`func-responses.klicker.com`)" + entrypoints: + - "web" + service: "func-responses" + + func-response-processor: + rule: "Host(`func-response-processor.klicker.com`)" + entrypoints: + - "web" + service: "func-response-processor" + + services: + api: + loadBalancer: + servers: + - url: "http://localhost:3000" + + pwa: + loadBalancer: + servers: + - url: "http://localhost:3001" + + manage: + loadBalancer: + servers: + - url: "http://localhost:3002" + + control: + loadBalancer: + servers: + - url: "http://localhost:3003" + + auth: + loadBalancer: + servers: + - url: "http://localhost:3010" + + func-responses: + loadBalancer: + servers: + - url: "http://localhost:7072" + + func-response-processor: + loadBalancer: + servers: + - url: "http://localhost:7073" From fb0531dc338a9134f47ead6725d1c9464166fe6d Mon Sep 17 00:00:00 2001 From: Roland Schlaefli Date: Fri, 27 Oct 2023 23:19:53 +0200 Subject: [PATCH 4/4] current progress with doppler trials --- .devcontainer/devcontainer.json | 39 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 73c9077457..3f89fc0d91 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,24 +1,33 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node-postgres { - "name": "KlickerUZH Dev Container", - "dockerComposeFile": "docker-compose.yml", - "service": "app", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "name": "KlickerUZH Dev Container", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/itsmechlark/features/doppler:2": {} + }, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // This can be used to network with other containers or with the host. - // "forwardPorts": [3000, 5432], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // This can be used to network with other containers or with the host. + // "forwardPorts": [3000, 5432], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pnpm install" + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pnpm install", + // Configure tool-specific properties. + // "customizations": {}, - // Configure tool-specific properties. - // "customizations": {}, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + // see https://github.com/DopplerUniversity/mandalorian-gifs-node/blob/main/.devcontainer/devcontainer.json + // start vscode from the terminal using doppler run -- code . + "containerEnv": { + "DOPPLER_PROJECT": "klicker-uzh", + "DOPPLER_CONFIG": "dev", + "DOPPLER_TOKEN": "${localEnv:DOPPLER_TOKEN}" // Don't hard-code this! + } }