diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..e69de29bb diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..90bb41594 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +# FROM gitlab/registry +FROM slimmed +MAINTAINER Gitlab + +# Initial build +# SSH authorized keys setup +# ADD ./doc/docker/ssh/authorized_keys /root/.ssh/authorized_keys +# +# Apache2 setup +# ADD ./doc/docker/apache2/ /etc/apache2/sites-enabled + +# Use baseimage-docker's init process. +CMD ["/sbin/my_init"] + +# Set correct environment variables. +ENV RAILS_ENV production +ENV HOME /home/app + +# Registry +WORKDIR /home/app/registry +ADD . /home/app/registry +RUN chown -R app:www-data .; chmod -R 750 .; chmod g+s .; umask 027 +RUN setuser app ls -la /home/app/registry/vendor/ +# RUN setuser app ls -la /home/app/registry/vendor/bundle +RUN rm /home/app/registry/vendor/bundle -rf +RUN setuser app bundle install --deployment +RUN setuser app rake assets:precompile + +# Registry test +WORKDIR /home/app/registry-test +ADD . /home/app/registry-test +RUN chown -R app:www-data .; chmod -R 750 .; chmod g+s .; umask 027 +RUN setuser app bundle install + +# Ports +# Registry admin: +EXPOSE 80 +# EPP: +EXPOSE 700 +# Test env what jenkins uses +# for debugging only: +# EXPOSE 81 + +# Clean up when done. +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/Gemfile b/Gemfile index d09f42fd6..ee2dcaa11 100644 --- a/Gemfile +++ b/Gemfile @@ -80,6 +80,7 @@ group :development, :test do gem 'capybara', '~> 2.4.1' # For feature testing # gem 'capybara-webkit', '1.2.0' # Webkit driver didn't work with turbolinks + gem 'phantomjs-binaries', '~> 1.9.2.4' gem 'phantomjs', '~> 1.9.7.1', require: 'phantomjs/poltergeist' gem 'poltergeist', '~> 1.5.1' # We are using PhantomJS instead @@ -108,3 +109,4 @@ group :development, :test do # For unique IDs (used by the epp gem) gem 'uuidtools', '~> 2.1.4' end + diff --git a/Gemfile.lock b/Gemfile.lock index cdb0ee83c..c4d3fcffb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,9 @@ GEM tzinfo (~> 1.1) arel (5.0.1.20140414130214) ast (2.0.0) - bootstrap-sass (3.2.0.1) + astrolabe (1.3.0) + parser (>= 2.2.0.pre.3, < 3.0) + bootstrap-sass (3.2.0.2) sass (~> 3.2) builder (3.2.2) byebug (2.7.0) @@ -41,17 +43,17 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - celluloid (0.15.2) - timers (~> 1.1.0) + celluloid (0.16.0) + timers (~> 4.0.0) cliver (0.3.2) coderay (1.1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) - coffee-script (2.2.0) + coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.7.0) + coffee-script-source (1.8.0) columnize (0.8.9) database_cleaner (1.3.0) debugger-linecache (1.2.0) @@ -60,7 +62,7 @@ GEM hpricot libxml-ruby erubis (2.7.0) - execjs (2.2.0) + execjs (2.2.1) fabrication (2.11.3) faker (1.3.0) i18n (~> 0.5) @@ -86,13 +88,14 @@ GEM haml (>= 3.1, < 5.0) railties (>= 4.0.1) hike (1.2.3) + hitimes (1.2.2) hpricot (0.8.6) i18n (0.6.11) isikukood (0.1.2) - jbuilder (2.1.1) + jbuilder (2.1.3) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) - jquery-rails (3.1.0) + jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) @@ -100,7 +103,7 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.9.2) - libv8 (3.16.14.3) + libv8 (3.16.14.5) libxml-ruby (2.7.0) listen (2.7.9) celluloid (>= 0.15.2) @@ -113,7 +116,7 @@ GEM method_source (0.8.2) mime-types (1.25.1) mini_portile (0.6.0) - minitest (5.4.0) + minitest (5.4.1) multi_json (1.10.1) nokogiri (1.6.2.1) mini_portile (= 0.6.0) @@ -123,6 +126,8 @@ GEM slop (~> 3.4, >= 3.4.5) pg (0.17.1) phantomjs (1.9.7.1) + phantomjs-binaries (1.9.2.4) + sys-uname (= 0.9.0) poltergeist (1.5.1) capybara (~> 2.1) cliver (~> 0.3.1) @@ -169,7 +174,7 @@ GEM rb-fsevent (0.9.4) rb-inotify (0.9.5) ffi (>= 0.5.0) - rdoc (4.1.1) + rdoc (4.1.2) json (~> 1.4) ref (1.0.5) rspec (3.0.0) @@ -192,7 +197,8 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.4) - rubocop (0.25.0) + rubocop (0.26.0) + astrolabe (~> 1.3) parser (>= 2.2.0.pre.4, < 3.0) powerpack (~> 0.0.6) rainbow (>= 1.99.1, < 3.0) @@ -204,10 +210,10 @@ GEM sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0) - sdoc (0.4.0) - json (~> 1.8) - rdoc (~> 4.0, < 5.0) - shoulda-matchers (2.6.1) + sdoc (0.4.1) + json (~> 1.7, >= 1.7.7) + rdoc (~> 4.0) + shoulda-matchers (2.6.2) activesupport (>= 3.0.0) simpleidn (0.0.5) slop (3.6.0) @@ -217,32 +223,35 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sprockets-rails (2.1.4) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) + sys-uname (0.9.0) + ffi (>= 1.0.0) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) - timers (1.1.0) + timers (4.0.1) + hitimes treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (2.2.2) + turbolinks (2.3.0) coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.5.1) + uglifier (2.5.3) execjs (>= 0.3.0) json (>= 1.8.0) unicorn (4.8.3) kgio (~> 2.6) rack raindrops (~> 0.7) - uuidtools (2.1.4) + uuidtools (2.1.5) websocket-driver (0.3.4) xpath (2.0.0) nokogiri (~> 1.3) @@ -270,6 +279,7 @@ DEPENDENCIES nprogress-rails (~> 0.1.3.1) pg phantomjs (~> 1.9.7.1) + phantomjs-binaries (~> 1.9.2.4) poltergeist (~> 1.5.1) pry (~> 0.10.1) pry-byebug (~> 1.3.3) diff --git a/config/application.rb b/config/application.rb index d3a18e95b..8e4a6a7c2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,7 +13,7 @@ require 'sprockets/railtie' # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module Internetee +module Registry class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers diff --git a/config/database-example.yml b/config/database-example.yml index 25eeaee5e..37e52ad97 100644 --- a/config/database-example.yml +++ b/config/database-example.yml @@ -3,13 +3,17 @@ default: &default adapter: postgresql encoding: unicode pool: 5 - username: internetee - password: internetee_pwd + username: registry + password: registry_pwd development: <<: *default - database: internetee_development + database: registry_development test: <<: *default - database: internetee_test + database: registry_test + +production: + <<: *default + database: registry_production diff --git a/config/initializers/load_validators.rb b/config/initializers/load_validators.rb index 92f534e30..ea84920bf 100644 --- a/config/initializers/load_validators.rb +++ b/config/initializers/load_validators.rb @@ -1 +1 @@ -Internetee::Application.config.autoload_paths += %W(#{Internetee::Application.config.root}/app/validators/) +Registry::Application.config.autoload_paths += %W(#{Registry::Application.config.root}/app/validators/) diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index dbb999454..480996245 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_internetee_session' +Rails.application.config.session_store :cookie_store, key: '_registry_session' diff --git a/config/secrets-example.yml b/config/secrets-example.yml index 23fedbe66..9a2adfb5d 100644 --- a/config/secrets-example.yml +++ b/config/secrets-example.yml @@ -5,4 +5,4 @@ test: secret_key_base: generate-your-secret-key-by-rake-secret production: - secret_key_base: + secret_key_base: please-change diff --git a/doc/docker/apache2/epp-tester.conf b/doc/docker/apache2/epp-tester.conf new file mode 100644 index 000000000..e3a428734 --- /dev/null +++ b/doc/docker/apache2/epp-tester.conf @@ -0,0 +1,18 @@ +Listen 8888 + + ServerName registry.gitlab.eu + ServerAdmin info@gitlab.eu + + PassengerEnabled on + RailsEnv production + DocumentRoot /home/app/epp-tester/public + + ErrorLog /var/log/apache2/epp-tester.error.log + LogLevel info ssl:warn + CustomLog /var/log/apache2/epp-tester.access.log combined + + + Require all granted + Options -MultiViews + + diff --git a/doc/docker/apache2/epp.conf b/doc/docker/apache2/epp.conf new file mode 100644 index 000000000..33ef057aa --- /dev/null +++ b/doc/docker/apache2/epp.conf @@ -0,0 +1,21 @@ + + Listen 700 + + SSLEngine on + SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL + SSLCertificateFile /etc/apache2/ssl/apache.crt + SSLCertificateKeyFile /etc/apache2/ssl/apache.key + + SSLVerifyClient optional_no_ca + + EPPEngine On + EPPCommandRoot /proxy/command + EPPSessionRoot /proxy/session + EPPErrorRoot /proxy/error + + ProxyPass /proxy/ http://localhost:80/epp/ + + EPPAuthURI implicit + EPPReturncodeHeader X-EPP-Returncode + + diff --git a/doc/docker/apache2/registry-test.conf b/doc/docker/apache2/registry-test.conf new file mode 100644 index 000000000..dc4b0cc26 --- /dev/null +++ b/doc/docker/apache2/registry-test.conf @@ -0,0 +1,39 @@ +Listen 81 + + ServerAdmin info@gitlab.eu + + PassengerEnabled on + RailsEnv test + DocumentRoot /home/app/registry-test/public + + ErrorLog /var/log/apache2/registry-test.error.log + LogLevel info ssl:warn + CustomLog /var/log/apache2/registry-test.access.log combined + + + Require all granted + Options -MultiViews + + + + + Listen 701 + + SSLEngine on + SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL + SSLCertificateFile /etc/apache2/ssl/apache.crt + SSLCertificateKeyFile /etc/apache2/ssl/apache.key + + SSLVerifyClient optional_no_ca + + EPPEngine On + EPPCommandRoot /proxy/command + EPPSessionRoot /proxy/session + EPPErrorRoot /proxy/error + + ProxyPass /proxy/ http://localhost:81/epp/ + + EPPAuthURI implicit + EPPReturncodeHeader X-EPP-Returncode + + diff --git a/doc/docker/apache2/registry.conf b/doc/docker/apache2/registry.conf new file mode 100644 index 000000000..938a23602 --- /dev/null +++ b/doc/docker/apache2/registry.conf @@ -0,0 +1,17 @@ + + ServerName registry.gitlab.eu + ServerAdmin info@gitlab.eu + + PassengerEnabled on + RailsEnv production + DocumentRoot /home/app/registry/public + + ErrorLog /var/log/apache2/registry.error.log + LogLevel info ssl:warn + CustomLog /var/log/apache2/registry.access.log combined + + + Require all granted + Options -MultiViews + + diff --git a/doc/docker/ssh/authorized_keys b/doc/docker/ssh/authorized_keys new file mode 100755 index 000000000..9266ca452 --- /dev/null +++ b/doc/docker/ssh/authorized_keys @@ -0,0 +1,3 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAz+n4Sln0oxme+9hyrgPud9k0C00Nm0T2YufHcQUAdtJssCfeKp2qo/gy0LmOXTB8efyavFn4NW2GZs8gxJ0BV5GoHLmnERAWDOi/wg3KLl4r/ei+HQX6Po/V7WOMHWzKPSSGtqW7cZc1g0y2ci571ZUmgEBoGoGPfoQToGEn2yV4hQmHIjbwtfNNCHx/i12DCoJnD+3cIvhHf4FbZRBW9Wu0I24iqLcxLOAwGWVsnzi0OqN+rj3DenPQfjcPhSsmTu+8mn2AIwMxWeLZSslEYfyBeo9dLBntj3dnxWpw/MJEfMmWgWKGqMaVGB731ZWDOrRrzgl5+s24YBv9LyYWyQ== +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXF8qkkQg8We6c2eCRQTuQUAffuDcYijlnVNAH0V7eUMxKC/9aPIhHaM9JVY4exXDVEQOK0+KsF6twTtewK8XBFfHXcOV3k+11KOJ1LsfphQIbwS9Qufw2maxCWJHxQwKGViGLqePuecQhfQ3UAVXZ1ZO7qGrLB9JBlRimbItJsG3F2o1T7pJAMucf+zCv5KmMeeddDyhAg2ufQHnuPKIMAgr4XH/TD4mg5tqORXCdk/2apuqUz35WqAyRNt/J66bTJOJ39QJv50cyT6/Bb74MNfJSejsM5EUnKF4Nq7edR8F8tlnXmL/wvvVs81oHywCnMqP8eEISLumy1nhNpgbn martin@gitlab.eu +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC13V94raEKiCzg4sACsIFxiHPcRSUryUHxXpcyHMi7OJvTtszOPR3hZnB36c0NxnznD0t3rH2n5vIX+tBmX+JND7bvM+YKgTGcGN+HvS08nSsvwHLie/UAHkWy/4xFvyKnq8MIZtYxkPdIGph6hFMr5LljJu05V08hZF09HutBsjXw5wmZRUJoD/Jl0FO/pf6WxH1VHjhz0kGuM8VREU2SC8uzV1AIZ86zsaxJld1m0doyt+arnJkPYgjXHHpu/IWzIHYjbVo5W8JmYagDCYxaPHN7EesHAEzFi1LDtq1aIrqWrczKaJGSryxSba6pnYiK69MTojF/SAXMsJ1u5q1P andres.kesk@gmail.com diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake index cc4a71430..a5999a605 100644 --- a/lib/tasks/test.rake +++ b/lib/tasks/test.rake @@ -1,35 +1,37 @@ -require 'rspec/core/rake_task' -require 'open3' +if Rails.env.test? + require 'rspec/core/rake_task' + require 'open3' -desc 'Run all specs against server' -task 'test' do - test_against_server { Rake::Task['spec'].invoke } -end + desc 'Run all specs against server' + task 'test' do + test_against_server { Rake::Task['spec'].invoke } + end -desc 'Run EPP specs against server' -task 'test:epp' do - test_against_server { Rake::Task['spec:epp'].invoke } -end + desc 'Run EPP specs against server' + task 'test:epp' do + test_against_server { Rake::Task['spec:epp'].invoke } + end -desc 'Run all but EPP specs' -RSpec::Core::RakeTask.new('test:other') do |t| - t.rspec_opts = '--tag ~epp' -end + desc 'Run all but EPP specs' + RSpec::Core::RakeTask.new('test:other') do |t| + t.rspec_opts = '--tag ~epp' + end -desc 'Run all but EPP specs' -RSpec::Core::RakeTask.new('test:all_but_features') do |t| - t.rspec_opts = '--tag ~feature' -end + desc 'Run all but EPP specs' + RSpec::Core::RakeTask.new('test:all_but_features') do |t| + t.rspec_opts = '--tag ~feature' + end -Rake::Task[:default].prerequisites.clear -task default: :test + Rake::Task[:default].prerequisites.clear + task default: :test -def test_against_server - stdin, stdout, stderr, wait_thr = Open3.popen3('unicorn -E test -p 8989') - pid = wait_thr.pid - begin - yield - ensure - `kill #{pid}` + def test_against_server + stdin, stdout, stderr, wait_thr = Open3.popen3('unicorn -E test -p 8989') + pid = wait_thr.pid + begin + yield + ensure + `kill #{pid}` + end end end