...
 
Commits (13)
......@@ -6,12 +6,16 @@ before_script:
- ./script/silent-quick-start
- bundle exec rake db:migrate RAILS_ENV=test
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
stages:
# FIXME Selenium tests are randomly failing and this avoid other tests to run.
- smoke-tests
- all-tests
- code-quality
- push-docker-hub
.cache: &cache
cache:
key: "$CI_BUILD_REF_NAME"
......@@ -60,6 +64,7 @@ cucumber-1:
<<: *cache
script: SLICE=1/2 bundle exec rake cucumber
stage: all-tests
cucumber-2:
<<: *retriable
<<: *cache
......@@ -71,26 +76,31 @@ selenium-1:
<<: *cache
script: SLICE=1/6 bundle exec rake selenium
stage: all-tests
selenium-2:
<<: *retriable
<<: *cache
script: SLICE=2/6 bundle exec rake selenium
stage: all-tests
selenium-3:
<<: *retriable
<<: *cache
script: SLICE=3/6 bundle exec rake selenium
stage: all-tests
selenium-4:
<<: *retriable
<<: *cache
script: SLICE=4/6 bundle exec rake selenium
stage: all-tests
selenium-5:
<<: *retriable
<<: *cache
script: SLICE=5/6 bundle exec rake selenium
stage: all-tests
selenium-6:
<<: *retriable
<<: *cache
......@@ -104,21 +114,25 @@ plugins-1:
<<: *cache
script: SLICE=1/5 bundle exec rake test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
plugins-2:
<<: *retriable
<<: *cache
script: SLICE=2/5 bundle exec rake test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
plugins-3:
<<: *retriable
<<: *cache
script: SLICE=3/5 bundle exec rake test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
plugins-4:
<<: *retriable
<<: *cache
script: SLICE=4/5 bundle exec rake test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
stage: all-tests
plugins-5:
<<: *retriable
<<: *cache
......@@ -134,7 +148,7 @@ cypress:
rubocop:
<<: *cache
script:
- rubocop
- rubocop
stage: code-quality
allow_failure: true
......@@ -150,10 +164,10 @@ code_quality:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
script:
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths:
- gl-code-quality-report.json
......@@ -162,3 +176,17 @@ code_quality:
stage: code-quality
only:
- tags
docker_push:
<<: *retriable
image: docker:latest
stage: push-docker-hub
services:
- docker:dind
before_script:
- echo "${CI_REGISTRY_PASSWORD}" | docker login --username "${CI_REGISTRY_USER}" --password-stdin "${CI_REGISTRY}"
script:
- docker build -f config/docker/prod/Dockerfile -t $IMAGE_TAG .
- docker push $IMAGE_TAG
only:
- tags
\ No newline at end of file
......@@ -503,9 +503,8 @@ DEPENDENCIES
rpush
rspec
rspec-rails
rubocop (~> 0.57.2)
rubocop
ruby-feedparser
ruby-progressbar (~> 1.7.0)
ruby_bosh (> 0.0.0)!
rubyzip
sass
......@@ -529,6 +528,3 @@ DEPENDENCIES
whenever
will_paginate
xss_terminate (= 0.0.0)!
BUNDLED WITH
1.16.1
FROM debian:jessie
FROM ruby:2.1.5
LABEL Maintainer="Noosfero Development Team <noosfero-dev@listas.softwarelivre.org>"
LABEL Description="This dockerfile builds a noosfero development environment."
......@@ -13,7 +14,6 @@ RUN echo "IRB.conf[:HISTORY_FILE] = '~/.irb-history'" >> .irbrc
WORKDIR /noosfero
ADD . /noosfero/
RUN ./script/quick-start -i
RUN bundle install
......
FROM debian:jessie
LABEL Maintainer="Noosfero Development Team <noosfero-dev@listas.softwarelivre.org>"
FROM ruby:2.1.5
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
EXPOSE 3000
# Set working directory
WORKDIR /noosfero
ADD . /noosfero/
RUN ./script/quick-start -i
RUN bundle install
COPY config/database.yml.docker config/database.yml
RUN echo "IRB.conf[:SAVE_HISTORY] = 100" >> .irbrc
RUN echo "IRB.conf[:HISTORY_FILE] = '~/.irb-history'" >> .irbrc
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
......@@ -35,25 +31,29 @@ if [ -f $dump_file ]; then
yes | bundle exec rake restore BACKUP=$dump_file
fi
if bundle exec rake db:exists; then
echo ">>>>> DATABASE DETECTED APPLYING MIGRATIONS <<<<<"
bundle exec rake db:migrate
else
if ! bundle exec rake db:exists; then
echo ">>>>> NO DATABASE DETECTED CREATING A NEW ONE <<<<<"
bundle exec rake db:schema:load
bundle exec rake db:migrate
bundle exec rake db:create
fi
if ! bundle exec rake db:tables:exists; then
echo ">>>>> NO DATABASE TABLES DETECTED LOADING SCHEMA <<<<<"
bundle exec rake db:schema:load
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"
echo ">>>>> DATABASE DETECTED APPLYING MIGRATIONS <<<<<"
bundle exec rake db:migrate
echo ">>>>> PID VERIFICATION <<<<<"
pidfile='/noosfero/tmp/pids/server.pid'
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
......
......@@ -11,4 +11,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:/dump
- 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:
......