Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
wip
.env | 2 + config/docker/dev/entrypoint.sh | 49 +++++++++++++++++++++++++ config/initializers/default_icon_theme.rb | 8 --- config/initializers/default_theme.rb | 2 config/initializers/rack_timeout.rb | 2 + docker-compose.yml | 46 +++++++++++++++++++++++
diff --git a/.env b/.env index df46afc3d4729e12867bdad574c299f8a3fcf42b..8cb6d47807b6769e0531502069d9a48a04b86b0d 100644 --- a/.env +++ b/.env @@ -17,6 +17,8 @@ # Max connections on db, need to be higher than the number of threads DB_POOL=20 +REDIS_HOST='redis://redis:6379/0' + # RollBar token #ROLLBAR_TOKEN='xxxxxxx' diff --git a/config/docker/dev/entrypoint.sh b/config/docker/dev/entrypoint.sh new file mode 100755 index 0000000000000000000000000000000000000000..3c70a35f4aec0f065a9f68d0d82320dd2111e5dc --- /dev/null +++ b/config/docker/dev/entrypoint.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +cmd="$@" + +bundle check || bundle install + +echo "copying config/database.yml.docker -> config/database.yml" +cp /noosfero/config/database.yml.docker /noosfero/config/database.yml + +function_postgres_ready() { +ruby << END +require 'pg' +begin + PG.connect(dbname: "$POSTGRES_DB", user: "$POSTGRES_USER", password: "$POSTGRES_PASSWORD", host: "postgres") +rescue + exit -1 +else + exit 0 +end +END +} + +until function_postgres_ready; do + >&2 echo "POSTGRES IS UNAVAILABLE, SLEEP" + sleep 1 +done + +echo "POSTGRES IS UP, CONTINUE" + +# XXX: There's a bug here, that our version doesn't have this db:exists task, +# so we cannot know when to do this + +#if bundle exec rake db:exists; then +# echo "RUNNING MIGRATIONS" +# bundle exec rake db:migrate +#else +# echo "SETTING THE DATABASE UP" +# bundle exec rake db:create +# bundle exec rake db:schema:load +# #/noosfero/script/sample-data +#fi + +pidfile='/noosfero/tmp/pids/server.pid' +if [ -f $pidfile ] ; then + echo 'Server PID file exists. Removing it...' + rm $pidfile +fi + +exec $cmd diff --git a/config/initializers/default_icon_theme.rb b/config/initializers/default_icon_theme.rb index 55b7ae1d277c6fe9328036bd26e93050ef20630d..29b9c8817cdb2d58b14cf4bbafb09c37d0e82257 100644 --- a/config/initializers/default_icon_theme.rb +++ b/config/initializers/default_icon_theme.rb @@ -1,13 +1,7 @@ if File.writable?(Rails.root) # create the symlink to the default theme if it does not exist default = Rails.root.join('public', 'designs', 'icons', 'default') - if !File.exists?(default) + unless File.directory?(default) File.symlink('tango', default) - end - - # create a symlink to system-wide Tango icon set if it does not exist - tango_symlink = Rails.root.join('public', 'designs', 'icons', 'tango', 'Tango') - if !File.exist?(tango_symlink) - File.symlink('/usr/share/icons/Tango', tango_symlink) end end diff --git a/config/initializers/default_theme.rb b/config/initializers/default_theme.rb index 42dcaeeed8b0df72ab1d7325cc7991e1b388e85f..e63d8214b97fde345b81b03267c37249f75ae8f0 100644 --- a/config/initializers/default_theme.rb +++ b/config/initializers/default_theme.rb @@ -1,7 +1,7 @@ if File.writable?(Rails.root) # create the symlink to the default theme if it does not exist default = Rails.root.join('public', 'designs', 'themes', 'default') - if !File.exists?(default) + unless File.directory?(default) File.symlink('noosfero', default) end end diff --git a/config/initializers/rack_timeout.rb b/config/initializers/rack_timeout.rb index 698b5d699c780f85613568cb42eb83c6e0c42038..fe0a572c65a75fa4361859e3d94c7f4383b88213 100644 --- a/config/initializers/rack_timeout.rb +++ b/config/initializers/rack_timeout.rb @@ -3,4 +3,6 @@ require 'rack-timeout' Rack::Timeout.service_timeout = 20 rescue LoadError # put 'rack-timeout' on config/Gemfile to use +rescue + puts "Could not set rack timeout" end diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..743408e4bb72b23bd75a662f8d3535de6ef3d001 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +version: "3" + +services: + postgres: + container_name: postgres + image: postgres:9.4 + environment: + POSTGRES_USER: noosfero + POSTGRES_PASSWORD: noosfero + POSTGRES_DB: noosfero_development + volumes: + - pg-data:/var/lib/postgresql/data + + noosfero: + container_name: noosfero + env_file: + - .env + build: + context: . + dockerfile: ./config/docker/dev/Dockerfile + stdin_open: true + tty: true + ports: + - 3000:3000 + depends_on: + - postgres + - redis + volumes: + - .:/noosfero + environment: + POSTGRES_HOST: postgres + POSTGRES_USER: noosfero + POSTGRES_PASSWORD: noosfero + POSTGRES_DB: noosfero_development + + redis: + container_name: redis + image: redis + volumes: + - redis:/data + ports: + - 6379:6379 + +volumes: + pg-data: {} + redis: