├── Dockerfile.web ├── Procfile ├── Dockerfile.jobs ├── Makefile ├── unicorn.rb ├── Dockerfile ├── LICENSE └── README.md /Dockerfile.web: -------------------------------------------------------------------------------- 1 | FROM hackedu/huginn 2 | CMD ["unicorn", "-p", "3000", "-c", "config/unicorn.rb", "-E", "production"] 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec unicorn -c config/unicorn/production.rb 2 | jobs: bundle exec rails runner bin/threaded.rb 3 | -------------------------------------------------------------------------------- /Dockerfile.jobs: -------------------------------------------------------------------------------- 1 | FROM hackedu/huginn 2 | CMD ["bundle", "exec", "rails", "runner", "bin/threaded.rb", "-E", \ 3 | "production"] 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BASE_IMG=hackedu/huginn 2 | WEB_IMG=$(BASE_IMG)-web 3 | JOBS_IMG=$(BASE_IMG)-jobs 4 | BUILD_CMD=docker build 5 | PUSH_CMD=docker push 6 | 7 | .PHONY: build push 8 | 9 | base: 10 | $(BUILD_CMD) -t $(BASE_IMG) . 11 | 12 | web: 13 | $(BUILD_CMD) -t $(WEB_IMG) - < Dockerfile.web 14 | 15 | jobs: 16 | $(BUILD_CMD) -t $(JOBS_IMG) - < Dockerfile.jobs 17 | 18 | build: base web jobs 19 | 20 | push: build 21 | $(PUSH_CMD) $(BASE_IMG) 22 | $(PUSH_CMD) $(WEB_IMG) 23 | $(PUSH_CMD) $(JOBS_IMG) 24 | -------------------------------------------------------------------------------- /unicorn.rb: -------------------------------------------------------------------------------- 1 | worker_processes 3 2 | timeout 30 3 | preload_app true 4 | 5 | before_fork do |server, worker| 6 | Signal.trap 'TERM' do 7 | puts 'Unicorn master intercepting TERM and sending myself QUIT instead' 8 | Process.kill 'QUIT', Process.pid 9 | end 10 | defined?(ActiveRecord::Base) and 11 | ActiveRecord::Base.connection.disconnect! 12 | end 13 | 14 | after_fork do |server, worker| 15 | Signal.trap 'TERM' do 16 | puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT' 17 | end 18 | defined?(ActiveRecord::Base) and 19 | ActiveRecord::Base.establish_connection 20 | end 21 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rails 2 | MAINTAINER Zach Latta 3 | 4 | ADD https://codeload.github.com/cantino/huginn/tar.gz/master \ 5 | /tmp/huginn.tar.gz 6 | RUN cd /tmp && \ 7 | tar xzf huginn.tar.gz && \ 8 | mv huginn-master /usr/src/app && \ 9 | rm huginn.tar.gz 10 | 11 | WORKDIR /usr/src/app 12 | 13 | # We set ON_HEROKU to true to make sure gems installed for Heroku, like 14 | # Unicorn, are installed. See 15 | # https://github.com/cantino/huginn/blob/master/Gemfile#L120 16 | RUN ON_HEROKU=true bundle install --without development test 17 | 18 | # Since we don't have Nginx or Apache sitting in front of Rails in this image, 19 | # we want Rails to serve the static assets. 20 | RUN sed -i \ 21 | 's/config.serve_static_assets = false/config.serve_static_assets = true/' \ 22 | config/environments/production.rb 23 | COPY ./unicorn.rb /usr/src/app/config/unicorn.rb 24 | 25 | # We set the APP_SECRET_TOKEN to 1 so Devise won't fail. Don't actually set it 26 | # to this when a container from this image is launched. 27 | RUN RAILS_ENV=production APP_SECRET_TOKEN=1 bundle exec rake assets:precompile 28 | 29 | EXPOSE 3000 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 hackEDU 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # huginn-docker 2 | 3 | This project contains a production-ready 4 | [Huginn](https://github.com/cantino/huginn) deployment with Docker. 5 | 6 | The following images are built from this project: 7 | 8 | * `hackedu/huginn` 9 | * `hackedu/huginn-web` 10 | * `hackedu/huginn-jobs` 11 | 12 | ## Usage 13 | 14 | Run database migrations (the host DB must by MySQL compatible): 15 | 16 | docker run --rm \ 17 | -e "RAILS_ENV=production" \ 18 | -e "DATABASE_NAME=TODO" \ 19 | -e "DATABASE_USERNAME=TODO" \ 20 | -e "DATABASE_PASSWORD=TODO" \ 21 | -e "DATABASE_HOST=todo.example.com" \ 22 | -e "DATABASE_PORT=TODO" \ 23 | -e "DATABASE_ENCODING=utf8mb4" \ 24 | -e "INVITATION_CODE=my-invitation-code" \ 25 | hackedu/huginn rake db:migrate 26 | 27 | Seed the database (optional): 28 | 29 | docker run --rm \ 30 | -e "RAILS_ENV=production" \ 31 | -e "DATABASE_NAME=TODO" \ 32 | -e "DATABASE_USERNAME=TODO" \ 33 | -e "DATABASE_PASSWORD=TODO" \ 34 | -e "DATABASE_HOST=todo.example.com" \ 35 | -e "DATABASE_PORT=TODO" \ 36 | -e "DATABASE_ENCODING=utf8mb4" \ 37 | -e "SEED_USERNAME=TODO" \ 38 | -e "SEED_PASSWORD=TODO" \ 39 | hackedu/huginn rake db:seed 40 | 41 | Launch a web instance: 42 | 43 | docker run -d \ 44 | -e "RAILS_ENV=production" \ 45 | -e "APP_SECRET_TOKEN=TODO (generate with rake secret)" \ 46 | -e "DATABASE_NAME=TODO" \ 47 | -e "DATABASE_USERNAME=TODO" \ 48 | -e "DATABASE_PASSWORD=TODO" \ 49 | -e "DATABASE_HOST=TODO" \ 50 | -e "DATABASE_PORT=TODO" \ 51 | -e "DATABASE_ENCODING=utf8mb4" \ 52 | -p 3000:3000 \ 53 | hackedu/huginn-web 54 | 55 | Launch a job worker instance: 56 | 57 | docker run -d \ 58 | -e "RAILS_ENV=production" \ 59 | -e "APP_SECRET_TOKEN=TODO (generate with rake secret)" \ 60 | -e "DATABASE_NAME=TODO" \ 61 | -e "DATABASE_USERNAME=TODO" \ 62 | -e "DATABASE_PASSWORD=TODO" \ 63 | -e "DATABASE_HOST=TODO" \ 64 | -e "DATABASE_PORT=TODO" \ 65 | -e "DATABASE_ENCODING=utf8mb4" \ 66 | -p 3000:3000 \ 67 | hackedu/huginn-jobs 68 | 69 | You can override any environment variables when launching Huginn containers. 70 | For a list, see the 71 | [.env.example](https://github.com/cantino/huginn/blob/master/.env.example) 72 | file. Do note that there are additional required variables in the list, you'll 73 | want to add them when deploying. 74 | 75 | ### Building 76 | 77 | Build all images: 78 | 79 | $ make build 80 | 81 | Push all images: 82 | 83 | $ make push 84 | 85 | The `push` target depends on the `build` target, so if you want to build and 86 | push, you only need to run `make push`. 87 | 88 | Note: If you want to change the name of the images, you need to change both the 89 | Makefile and the web and jobs Dockerfiles. 90 | 91 | ## License 92 | 93 | The MIT License (MIT) 94 | 95 | Copyright (c) 2019 Hack Club 96 | 97 | Permission is hereby granted, free of charge, to any person obtaining a copy of 98 | this software and associated documentation files (the "Software"), to deal in 99 | the Software without restriction, including without limitation the rights to 100 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 101 | of the Software, and to permit persons to whom the Software is furnished to do 102 | so, subject to the following conditions: 103 | 104 | The above copyright notice and this permission notice shall be included in all 105 | copies or substantial portions of the Software. 106 | 107 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 108 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 109 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 110 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 111 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 112 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 113 | SOFTWARE. 114 | --------------------------------------------------------------------------------