From 0b7873871affe2d03ffec368f5dd9a6c8e724f0d Mon Sep 17 00:00:00 2001 From: decentral1se Date: Mon, 17 May 2021 15:54:59 +0200 Subject: [PATCH] Take a run at bootstrapping this --- .env.sample | 4 ++-- README.md | 26 ++++++++++++++++---------- abra.sh | 1 + compose.yml | 41 +++++++++++++++++++++++++++++++++-------- entrypoint.sh.tmpl | 27 +++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 20 deletions(-) create mode 100644 abra.sh create mode 100644 entrypoint.sh.tmpl diff --git a/.env.sample b/.env.sample index 607ff90..a3a0b9f 100644 --- a/.env.sample +++ b/.env.sample @@ -1,6 +1,6 @@ TYPE=rstudio DOMAIN=rstudio.example.com -## Domain aliases -#EXTRA_DOMAINS=', `www.rstudio.example.com`' LETS_ENCRYPT_ENV=production + +SECRET_ADMIN_PASSWORD_VERSION=v1 diff --git a/README.md b/README.md index 932a138..1fdd141 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,22 @@ -# Rstudio +# rstudio -An integrated development environment for R and Python, with a console, syntax-highlighting editor that supports direct code execution, and tools for plotting, history, debugging and workspace management. +> https://www.rocker-project.org/images + +An integrated development environment for R and Python, with a console, +syntax-highlighting editor that supports direct code execution, and tools for +plotting, history, debugging and workspace management. -* **Category**: -* **Status**: -* **Image**: [`rstudio`](https://hub.docker.com/r/rstudio/rstudio) -* **Healthcheck**: -* **Backups**: -* **Email**: -* **Tests**: -* **SSO**: + +- **Category**: +- **Status**: +- **Image**: [`rocker/tidyverse`](https://hub.docker.com/r/rocker/tidyverse) +- **Healthcheck**: +- **Backups**: +- **Email**: +- **Tests**: +- **SSO**: + ## Basic usage diff --git a/abra.sh b/abra.sh new file mode 100644 index 0000000..5bf044b --- /dev/null +++ b/abra.sh @@ -0,0 +1 @@ +export CUSTOM_ENTRYPOINT_VERSION=v1 diff --git a/compose.yml b/compose.yml index 662a96c..217dd04 100644 --- a/compose.yml +++ b/compose.yml @@ -3,29 +3,54 @@ version: "3.8" services: app: - image: nginx:1.19.2 + image: rocker/tidyverse:4.0.4 networks: - proxy + volumes: + - home:/home + secrets: + - admin_password + environment: + - ROOT=TRUE + - PASSWORD_FILE=/run/secrets/admin_password + configs: + - source: custom_entrypoint + target: /usr/local/bin/docker-entrypoint.sh + mode: 0555 + entrypoint: /usr/local/bin/docker-entrypoint.sh + command: /init deploy: restart_policy: condition: on-failure labels: - "traefik.enable=true" - - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80" - - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})" + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=8787" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)" - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" - ## Redirect from EXTRA_DOMAINS to DOMAIN - #- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect" - #- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true" - #- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" + entrypoint: + healthcheck: - test: ["CMD", "curl", "-f", "http://localhost"] + test: + ["CMD-SHELL", "wget -q --spider --proxy=off localhost:8787 || exit 1"] interval: 30s timeout: 10s retries: 10 start_period: 1m +volumes: + home: + networks: proxy: external: true + +configs: + custom_entrypoint: + name: ${STACK_NAME}_custom_entrypoint_${CUSTOM_ENTRYPOINT_VERSION} + file: entrypoint.sh.tmpl + +secrets: + admin_password: + name: ${STACK_NAME}_admin_password_${SECRET_ADMIN_PASSWORD_VERSION} + external: true diff --git a/entrypoint.sh.tmpl b/entrypoint.sh.tmpl new file mode 100644 index 0000000..c6a109f --- /dev/null +++ b/entrypoint.sh.tmpl @@ -0,0 +1,27 @@ +#!/bin/bash + +set -e + +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + + local val="$def" + + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + + export "$var"="$val" + unset "$fileVar" +} + +file_env "PASSWORD"