From 7b3943052e597fcac66b7c78a375e2cf9d1440d6 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Mon, 28 Oct 2019 21:11:21 +0200 Subject: [PATCH] Move the setup scripts to their own home (#4310) --- setup/README.md | 22 ++---------- setup/docker-compose.yml | 52 ---------------------------- setup/generate_key.sh | 21 ------------ setup/packer.json | 65 ----------------------------------- setup/setup.sh | 73 ---------------------------------------- 5 files changed, 2 insertions(+), 231 deletions(-) delete mode 100644 setup/docker-compose.yml delete mode 100644 setup/generate_key.sh delete mode 100644 setup/packer.json delete mode 100644 setup/setup.sh diff --git a/setup/README.md b/setup/README.md index 56373e9697..6054e60137 100644 --- a/setup/README.md +++ b/setup/README.md @@ -1,23 +1,5 @@ # Setup script for Redash with Docker on Ubuntu 18.04. -This is a reference setup for Redash on a single Ubuntu 18.04 server, which uses Docker and Docker Compose for deployment and management. +The setup script moved to its own repository: -This is the same setup we use for our official images (for AWS & Google Cloud) and can be used as reference if you want to manually setup Redash in a different environment (different OS or different deployment location). - -* `setup.sh` is the script that installs everything and creates the directories. -* `docker-compose.yml` is the Docker Compose setup we use. -* `packer.json` is Packer configuration we use to create the Cloud images. - -## FAQ - -### Can I use this in production? - -For small scale deployments -- yes. But for larger deployments we recommend at least splitting the database (and probably Redis) into its own server (preferably a managed service like RDS) and setting up at least 2 servers for Redash for redundancy. You will also need to tweak the number of workers based on your usage patterns. - -### How do I upgrade to newer versions of Redash? - -See [Upgrade Guide](https://redash.io/help/open-source/admin-guide/how-to-upgrade). - -### How do I use `setup.sh` on a different operating system? - -You will need to update the `install_docker` function and maybe other functions as well. +[https://github.com/getredash/setup](https://github.com/getredash/setup) diff --git a/setup/docker-compose.yml b/setup/docker-compose.yml deleted file mode 100644 index aea6369b5d..0000000000 --- a/setup/docker-compose.yml +++ /dev/null @@ -1,52 +0,0 @@ -version: '2' -x-redash-service: &redash-service - image: redash/redash:7.0.0.b18042 - depends_on: - - postgres - - redis - env_file: /opt/redash/env - restart: always -services: - server: - <<: *redash-service - command: server - ports: - - "5000:5000" - environment: - REDASH_WEB_WORKERS: 4 - scheduler: - <<: *redash-service - command: scheduler - environment: - QUEUES: "celery" - WORKERS_COUNT: 1 - scheduled_worker: - <<: *redash-service - command: worker - environment: - QUEUES: "scheduled_queries,schemas" - WORKERS_COUNT: 1 - adhoc_worker: - <<: *redash-service - command: worker - environment: - QUEUES: "queries" - WORKERS_COUNT: 2 - redis: - image: redis:5.0-alpine - restart: always - postgres: - image: postgres:9.5-alpine - env_file: /opt/redash/env - volumes: - - /opt/redash/postgres-data:/var/lib/postgresql/data - restart: always - nginx: - image: redash/nginx:latest - ports: - - "80:80" - depends_on: - - server - links: - - server:redash - restart: always diff --git a/setup/generate_key.sh b/setup/generate_key.sh deleted file mode 100644 index 93b97a0ea6..0000000000 --- a/setup/generate_key.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -FLAG="/var/log/generate_secrets.log" -if [ ! -f $FLAG ]; then - COOKIE_SECRET=$(pwgen -1s 32) - SECRET_KEY=$(pwgen -1s 32) - POSTGRES_PASSWORD=$(pwgen -1s 32) - REDASH_DATABASE_URL="postgresql:\/\/postgres:$POSTGRES_PASSWORD@postgres\/postgres" - - sed -i "s/REDASH_COOKIE_SECRET=.*/REDASH_COOKIE_SECRET=$COOKIE_SECRET/g" /opt/redash/env - sed -i "s/REDASH_SECRET_KEY=.*/REDASH_SECRET_KEY=$SECRET_KEY/g" /opt/redash/env - sed -i "s/POSTGRES_PASSWORD=.*/POSTGRES_PASSWORD=$POSTGRES_PASSWORD/g" /opt/redash/env - sed -i "s/REDASH_DATABASE_URL=.*/REDASH_DATABASE_URL=$REDASH_DATABASE_URL/g" /opt/redash/env - - #the next line creates an empty file so it won't run the next boot - echo "$(date) Updated secrets." >> $FLAG -else - echo "Secrets already set, skipping." -fi - -exit 0 diff --git a/setup/packer.json b/setup/packer.json deleted file mode 100644 index 1f004ddd9b..0000000000 --- a/setup/packer.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "variables": { - "redash_version": "", - "image_version": "" - }, - "builders": [ - { - "name": "redash-us-east-1", - "type": "amazon-ebs", - "region": "us-east-1", - "source_ami": "ami-0ac019f4fcb7cb7e6", - "instance_type": "t2.micro", - "ssh_username": "ubuntu", - "ami_name": "redash-{{user `image_version`}}-us-east-1" - }, - { - "type": "googlecompute", - "project_id": "redash-bird-123", - "source_image_family": "ubuntu-1804-lts", - "zone": "us-central1-a", - "ssh_username": "arik" - } - ], - "provisioners": [ - { - "type": "shell", - "inline": [ - "sleep 30" - ] - }, - { - "type": "shell", - "script": "setup.sh", - "execute_command": "{{ .Vars }} sudo -E -S bash '{{ .Path }}'", - "environment_vars": ["REDASH_VERSION={{user `redash_version`}}"] - }, - { - "type": "shell", - "inline": "sudo rm /root/.ssh/authorized_keys || true" - }, - { - "type": "shell", - "inline": "sudo rm /home/ubuntu/.ssh/authorized_keys || true" - }, - { - "type": "file", - "source": "generate_key.sh", - "destination": "/tmp/rc.local" - }, - { - "type": "shell", - "inline": ["sudo mv /tmp/rc.local /etc/rc.local", "sudo chown root /etc/rc.local", "sudo chmod 755 /etc/rc.local"] - } - ], - "post-processors": [ - { - "type": "googlecompute-export", - "only": ["googlecompute"], - "paths": [ - "gs://redash-images/redash.{{user `redash_version`}}.tar.gz" - ], - "keep_input_artifact": true - } - ] -} diff --git a/setup/setup.sh b/setup/setup.sh deleted file mode 100644 index 9164b6fef0..0000000000 --- a/setup/setup.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash -# This script setups dockerized Redash on Ubuntu 18.04. -set -eu - -REDASH_BASE_PATH=/opt/redash - -install_docker(){ - # Install Docker - sudo apt-get update - sudo apt-get -yy install apt-transport-https ca-certificates curl software-properties-common wget pwgen - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get update && sudo apt-get -y install docker-ce - - # Install Docker Compose - sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - - # Allow current user to run Docker commands - sudo usermod -aG docker $USER -} - -create_directories() { - if [[ ! -e $REDASH_BASE_PATH ]]; then - sudo mkdir -p $REDASH_BASE_PATH - sudo chown $USER:$USER $REDASH_BASE_PATH - fi - - if [[ ! -e $REDASH_BASE_PATH/postgres-data ]]; then - mkdir $REDASH_BASE_PATH/postgres-data - fi -} - -create_config() { - if [[ -e $REDASH_BASE_PATH/env ]]; then - rm $REDASH_BASE_PATH/env - touch $REDASH_BASE_PATH/env - fi - - COOKIE_SECRET=$(pwgen -1s 32) - SECRET_KEY=$(pwgen -1s 32) - POSTGRES_PASSWORD=$(pwgen -1s 32) - REDASH_DATABASE_URL="postgresql://postgres:${POSTGRES_PASSWORD}@postgres/postgres" - - echo "PYTHONUNBUFFERED=0" >> $REDASH_BASE_PATH/env - echo "REDASH_LOG_LEVEL=INFO" >> $REDASH_BASE_PATH/env - echo "REDASH_REDIS_URL=redis://redis:6379/0" >> $REDASH_BASE_PATH/env - echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $REDASH_BASE_PATH/env - echo "REDASH_COOKIE_SECRET=$COOKIE_SECRET" >> $REDASH_BASE_PATH/env - echo "REDASH_SECRET_KEY=$SECRET_KEY" >> $REDASH_BASE_PATH/env - echo "REDASH_DATABASE_URL=$REDASH_DATABASE_URL" >> $REDASH_BASE_PATH/env -} - -setup_compose() { - REQUESTED_CHANNEL=stable - LATEST_VERSION=`curl -s "https://version.redash.io/api/releases?channel=$REQUESTED_CHANNEL" | json_pp | grep "docker_image" | head -n 1 | awk 'BEGIN{FS=":"}{print $3}' | awk 'BEGIN{FS="\""}{print $1}'` - - cd $REDASH_BASE_PATH - REDASH_BRANCH="${REDASH_BRANCH:-master}" # Default branch/version to master if not specified in REDASH_BRANCH env var - wget https://raw.githubusercontent.com/getredash/redash/${REDASH_BRANCH}/setup/docker-compose.yml - sed -ri "s/image: redash\/redash:([A-Za-z0-9.-]*)/image: redash\/redash:$LATEST_VERSION/" docker-compose.yml - echo "export COMPOSE_PROJECT_NAME=redash" >> ~/.profile - echo "export COMPOSE_FILE=$REDASH_BASE_PATH/docker-compose.yml" >> ~/.profile - export COMPOSE_PROJECT_NAME=redash - export COMPOSE_FILE=$REDASH_BASE_PATH/docker-compose.yml - sudo docker-compose run --rm server create_db - sudo docker-compose up -d -} - -install_docker -create_directories -create_config -setup_compose