...
 
Commits (16)
......@@ -345,7 +345,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.1)
rake (12.3.2)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
......@@ -583,4 +583,4 @@ DEPENDENCIES
xss_terminate (= 0.0.0)!
BUNDLED WITH
1.17.0
1.17.1
......@@ -7,13 +7,12 @@ EXPOSE 3000
RUN apt-get update && apt-get install -y sudo cron nodejs postgresql-client
WORKDIR /root
RUN echo "IRB.conf[:SAVE_HISTORY] = 100" >> .irbrc
RUN echo "IRB.conf[:HISTORY_FILE] = '~/.irb-history'" >> .irbrc
WORKDIR /noosfero
ADD . /noosfero/
RUN echo "IRB.conf[:SAVE_HISTORY] = 100" >> .irbrc
RUN echo "IRB.conf[:HISTORY_FILE] = '~/.irb-history'" >> .irbrc
RUN ./script/quick-start -i
ENTRYPOINT ["/noosfero/config/docker/dev/entrypoint.sh"]
......
FROM ruby:2.4.4-jessie
LABEL Maintainer="Noosfero Development Team <noosfero-dev@listas.softwarelivre.org>"
FROM ruby:2.3-stretch
LABEL Maintainer="Noosfero Development Team <noosfero-dev@listas.softwarelivre.org>"
LABEL Description="This dockerfile builds a noosfero production environment."
EXPOSE 3000
ENV RAILS_ENV production
RUN apt-get update && apt-get install -y sudo cron nodejs postgresql-client
WORKDIR /noosfero
ADD . /noosfero/
RUN ./script/quick-start -i
RUN bundle install
COPY config/database.yml.docker config/database.yml
ENTRYPOINT ["/noosfero/config/docker/prod/entrypoint.sh"]
RUN bundle install --jobs 20 --retry 5 --without development test
CMD ["/noosfero/script/production", "run"]
ENTRYPOINT ["config/docker/prod/noosfero-entrypoint.sh"]
CMD ["script/production", "run"]
FROM httpd:2.4.35
RUN apt-get update -qq && \
apt-get install -y apache2
EXPOSE 80
ARG MYSITE
RUN a2enmod deflate expires proxy proxy_balancer proxy_http rewrite
COPY ./templates/mysite.template /etc/apache2/sites-available/$MYSITE
COPY ./apache-start.sh /bin/apache-start.sh
RUN a2ensite $MYSITE
CMD ["invoke-rc.d", "apache2", "restart"]
ENTRYPOINT ["sh", "/bin/apache-start.sh"]
#!/bin/bash
service apache2 start
tail -f /dev/null
#!/bin/bash
envsubst \$NOOSFERO_DOMAIN < /tmp/nginx.template > /tmp/nginx-v2.template
envsubst \$NOOSFERO_PATH < /tmp/nginx-v2.template > /etc/nginx/conf.d/default.conf
exec nginx -g 'daemon off;'
#!/bin/bash
cmd="$@"
echo "copying config/database.yml.docker -> config/database.yml"
cp /noosfero/config/database.yml.docker /noosfero/config/database.yml
set -e
function_postgres_ready() {
ruby << END
......@@ -40,19 +36,21 @@ if bundle exec rake db:exists; then
bundle exec rake db:migrate
else
echo ">>>>> NO DATABASE DETECTED CREATING A NEW ONE <<<<<"
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:migrate
echo ">>>>> CREATING DEFAULT ENVIRONMENT AND ADMIN USER <<<<<"
bundle exec rake db:data:minimal
fi
echo ">>>>> PID VERIFICATION <<<<<"
pidfiles="/noosfero/tmp/pids/*.*"
rm -rf $pidfiles
echo "PID folder is now clean"
pidfile='/noosfero/tmp/pids/*.*'
if [ -f $pidfile ] ; then
echo 'Server PID file exists. Removing it...'
rm $pidfile
fi
echo ">>>>> COMPILING ASSETS <<<<<"
bundle exec rake assets:precompile
exec $cmd
exec "$@"
MYSITE=my_site_name
DOMAIN=my-site.com
NOOSFERO_DOMAIN=noosfero.localhost
NOOSFERO_PATH=/noosfero
POSTGRES_HOST=postgres
POSTGRES_USER=noosfero
......@@ -9,7 +8,9 @@ VCL_CONFIG=/etc/varnish/default.vcl
NOOSFERO_DUMP_FILE=
# Set your custom environment configs
ENVIRONMENT_NAME=Noosfero
ENVIRONMENT_THEME=default
# Set your custom credentials if you want to create a default admin account
#ADMIN_LOGIN=
#ADMIN_EMAIL=
#ADMIN_PASSWORD=
ADMIN_LOGIN=adminuser
ADMIN_EMAIL=adminuser@localhost.localdomain
ADMIN_PASSWORD=adminuser
RAILS_ENV=production
upstream rails_app {
server noosfero:3000;
}
server {
# define your domain
server_name $NOOSFERO_DOMAIN;
# define the public application root
root $NOOSFERO_PATH/public;
index index.html;
# define where Nginx should write its logs
access_log $NOOSFERO_PATH/log/nginx.access.log;
error_log $NOOSFERO_PATH/log/nginx.error.log;
# deny requests for files that should never be accessed
location ~ /\. {
deny all;
}
location ~* ^.+\.(rb|log)$ {
deny all;
}
# serve static (compiled) assets directly if they exist (for rails production)
location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ {
try_files $uri $uri.html @rails;
access_log off;
gzip_static on;
# to serve pre-gzipped version
expires max;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
break;
}
# send non-static file requests to the app server
location / {
try_files $uri $uri.html @rails;
}
location @rails {
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://rails_app;
}
}
# vim: ft=conf
......@@ -2,8 +2,9 @@ namespace :db do
namespace :data do
task :minimal do
name = ENV['ENVIRONMENT_NAME'] || 'Noosfero'
theme = ENV['ENVIRONMENT_THEME'] ||'default'
email = ENV['ADMIN_EMAIL'] ||'noosfero@localhost.localdomain'
sh 'rails', 'runner', "Environment.create!(:name => '#{name}', :contact_email => '#{email}', :is_default => true) unless Environment.default"
sh 'rails', 'runner', "Environment.create!(:name => '#{name}', :theme => '#{theme}', :contact_email => '#{email}', :is_default => true) unless Environment.default"
unless ENV['NOOSFERO_DOMAIN'].blank?
sh 'rails', 'runner', "Environment.default.domains << Domain.new(:name => ENV['NOOSFERO_DOMAIN'])"
end
......@@ -14,7 +15,7 @@ namespace :db do
:password => ENV['ADMIN_PASSWORD'],
:password_confirmation => ENV['ADMIN_PASSWORD'],
:environment => Environment.default)
admin.activate
admin.activate!
Environment.default.add_admin(admin.person)"
end
end
......
......@@ -12,4 +12,17 @@ namespace :db do
exit 0
end
end
namespace :tables do
task :exists do
begin
# It will fail if the table 'environments' does not exist
Environment.count
rescue
exit 1
else
exit 0
end
end
end
end
......@@ -2,37 +2,6 @@ version: "3.5"
services:
varnish:
container_name: varnish
privileged: true
build:
context: ./config/docker/prod/
dockerfile: ./Dockerfile-varnish
networks:
- noosfero-net
volumes:
- apache2:/etc/apache2/
- /var/lib/varnish/:/var/lib/varnish/
- /etc/default/:/etc/default/
- /etc/varnish/:/etc/varnish/
env_file:
- config/docker/prod/production.env
depends_on:
- apache2
apache2:
container_name: apache2
build:
context: ./config/docker/prod/
dockerfile: ./Dockerfile-apache2
networks:
- noosfero-net
restart: always
env_file:
- config/docker/prod/production.env
volumes:
- apache2:/etc/apache2/
postgres:
container_name: postgres
image: postgres:9.4
......@@ -52,16 +21,37 @@ services:
- 3000:3000
depends_on:
- postgres
volumes:
- ./tmp/backup:/dump
networks:
- noosfero-net
env_file:
- config/docker/prod/production.env
volumes:
- ./tmp/backup:/tmp/backup
- noosfero-public:/noosfero/public
- noosfero-log:/noosfero/log
nginx:
container_name: nginx
image: nginx:1.14
depends_on:
- noosfero
ports:
- 80:80
networks:
- noosfero-net
env_file:
- config/docker/prod/production.env
volumes:
- noosfero-public:/noosfero/public
- noosfero-log:/noosfero/log
- ./config/docker/prod/nginx-start.sh:/tmp/nginx-start.sh
- ./config/docker/prod/templates/nginx.template:/tmp/nginx.template
command: /tmp/nginx-start.sh
volumes:
pg-prod-data: {}
apache2:
noosfero-public:
noosfero-log:
networks:
noosfero-net:
......