From f3949ce553bc52061b1e25675a52ecf50433b39f Mon Sep 17 00:00:00 2001 From: Bartosz Ptaszynski Date: Tue, 29 Nov 2016 19:23:18 +0000 Subject: [PATCH] fixes #225 - dockerized problem in the sidekiq-in-container --- Dockerfile | 4 ++-- README.md | 16 +++++++------- docker-compose.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index c6721b4..4400133 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,7 +86,7 @@ RUN rbenv local $RUBY_VERSION && \ mkdir -p tmp && \ touch tmp/restart.txt -VOLUME ["/app/config", "/app/log"] +VOLUME ["/app/config", "/app/log", "/app/uploads"] # 172.17.42.1 is the docker0 address ENV DATABASE_URL "postgresql://postgres:mypass@172.17.42.1/asciinema" @@ -95,7 +95,7 @@ ENV RAILS_ENV "development" # when using Docker Toolbox/Virtualbox this is going to be your address # set to whatever FQDN/address you want asciinema to advertise itself as # for ex. asciinema.example.com -ENV HOST "192.168.99.100:3000" +ENV HOST "localhost:3000" ENTRYPOINT ["rbenv", "exec"] CMD ["bundle", "exec", "rails", "server"] diff --git a/README.md b/README.md index 7d7f486..548b7fa 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,16 @@ Below you'll find setup instructions in case you want to contribute, play with it on your local machine, or setup your own instance for private use or for your organization. -### Using Docker +### Quickstart Using Docker Compose +Required: + - [Docker](https://docs.docker.com/engine/getstarted/step_one/#step-1-get-docker) + - [docker-compose 1.5+](https://docs.docker.com/compose/install/) ```bash -$ docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=mypass --name=postgres postgres -$ docker run -d -p 6379:6379 --name=redis redis -$ docker run --rm --link postgres:postgres -e DATABASE_URL="postgresql://postgres:mypass@postgres/asciinema" --link redis:redis -e REDIS_URL="redis://redis:6379" asciinema/asciinema.org bundle exec rake db:setup -# starting sidekiq using the provided start_sidekiq.rb file will also start sendmail service if you don't want to use SMTP -# otherwise start sidekiq by starting: bundle exec sidekiq -$ docker run -d --link postgres:postgres -e DATABASE_URL="postgresql://postgres:mypass@postgres/asciinema" --link redis:redis -e REDIS_URL="redis://redis:6379" asciinema/asciinema.org ruby start_sidekiq.rb -$ docker run -d --link postgres:postgres -e DATABASE_URL="postgresql://postgres:mypass@postgres/asciinema" --link redis:redis -e REDIS_URL="redis://redis:6379" -p 3000:3000 asciinema/asciinema.org +$ wget https://raw.githubusercontent.com/asciinema/asciinema.org/master/docker-compose.yml +$ docker-compose up -d asciinema +$ docker-compose run --rm db_init + ``` You can override the address/port that is sent in email with login token by passing HOST="host:port" environment variable when starting the web server. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..398537a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,55 @@ +version: '2' + +# Quickstart: +# docker-compose up -d asciinema +# docker-compose run --rm db_init + +# To cleanup: +# docker-compose stop && docker-compose rm + +services: + postgres: + image: postgres + container_name: postgres + redis: + image: redis + container_name: redis + sidekiq: + image: asciinema/asciinema.org + links: + - redis + - postgres + environment: + DATABASE_URL: "postgresql://postgres:mypass@postgres/asciinema" + REDIS_URL: "redis://redis:6379" + HOST: "localhost:3000" + command: "ruby start_sidekiq.rb" + volumes: + - /tmp/asciinema/uploads:/app/uploads + + asciinema: + image: asciinema/asciinema.org + container_name: asciinema + links: + - redis + - postgres + depends_on: + - sidekiq + environment: + DATABASE_URL: "postgresql://postgres:mypass@postgres/asciinema" + REDIS_URL: "redis://redis:6379" + HOST: "localhost:3000" # replace with actual hostname/ip.... ${HOSTNAME} doesn't seem to work.. + ports: + - "3000:3000" + volumes: + - /tmp/asciinema/uploads:/app/uploads + + db_init: + image: asciinema/asciinema.org + links: + - redis + - postgres + environment: + DATABASE_URL: "postgresql://postgres:mypass@postgres/asciinema" + REDIS_URL: "redis://redis:6379" + command: "bundle exec rake db:setup"