Issue Summary

I did some very small changes to the Frontend code of the branch release/7.0.x. I was able to test my changes using the Simple development setup. I now want to deploy the changes but it is not mentioned how to deploy this, since the setup.sh script uses an existing redash docker image and the development docker-compose.yml is only for development purposes.

Does anyone have a docker-compose file for deployment of own code? Or does anyone know on how I must adapt the deployment docker compose file or the setup.sh to build my own code?

Technical details:

  • Redash Version: 7.0.x
  • Browser/OS: Ubuntu 18.04
  • How did you install Redash: docker-compose

I was looking for this and then gave up. Any pointer would be highly helpful Thanks

I found a way to deploy, it is currently a bit hacky but it does the job for me.

I have updated the docker-compose.yml from the setup directory and the setup.sh script.
I have also put both these files in the root of the redash repository.

setup.sh

#!/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() {
    echo "export COMPOSE_PROJECT_NAME=redash" >> ~/.profile
    echo "export COMPOSE_FILE=./docker-compose.yml" >> ~/.profile
    export COMPOSE_PROJECT_NAME=redash
    export COMPOSE_FILE=./docker-compose.yml
    # build the new docker image and it will be tagged as redash:latest
    sudo docker build -t redash .
    sudo docker-compose run --rm server create_db
    sudo docker-compose up -d
}
install_docker
create_directories
create_config
setup_compose

Here the image redash:latest is used which was generated by the script above.

docker-compose.yml

version: '2'
x-redash-service: &redash-service
  image: redash:latest
  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

Could you explain how the script builds the custom image and not Redash default image. I compared your setup.sh with Redash’s own script and I only found some missing lines that build the redash image.