From cd82693cb1ceee20f759b742d0df3b42d9ac212c Mon Sep 17 00:00:00 2001 From: Priit Tamboom Date: Mon, 22 Sep 2014 11:56:17 +0300 Subject: [PATCH] Added mina deploy --- Dockerfile | 29 ++++++----- config/deploy.rb | 80 ++++++++++++++++++++++++++++++ doc/docker/apache2/epp-tester.conf | 4 +- doc/docker/apache2/registry.conf | 4 +- 4 files changed, 98 insertions(+), 19 deletions(-) create mode 100644 config/deploy.rb diff --git a/Dockerfile b/Dockerfile index 90bb41594..0d98e21a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# FROM gitlab/registry -FROM slimmed +FROM gitlab/registry MAINTAINER Gitlab # Initial build @@ -7,7 +6,7 @@ MAINTAINER Gitlab # ADD ./doc/docker/ssh/authorized_keys /root/.ssh/authorized_keys # # Apache2 setup -# ADD ./doc/docker/apache2/ /etc/apache2/sites-enabled +ADD ./doc/docker/apache2/ /etc/apache2/sites-enabled # Use baseimage-docker's init process. CMD ["/sbin/my_init"] @@ -17,20 +16,20 @@ 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 +# 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 +# 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: diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 000000000..377b6060d --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,80 @@ +require 'mina/bundler' +require 'mina/rails' +require 'mina/git' +# require 'mina/rbenv' # for rbenv support. (http://rbenv.org) +# require 'mina/rvm' # for rvm support. (http://rvm.io) + +# Basic settings: +# domain - The hostname to SSH to. +# deploy_to - Path to deploy into. +# repository - Git repo to clone from. (needed by mina/git) +# branch - Branch name to deploy. (needed by mina/git) + +set :domain, 'testregistry' +set :deploy_to, '/home/app/registry' +set :repository, 'https://github.com/internetee/registry' +set :branch, 'master' + +# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server. +# They will be linked in the 'deploy:link_shared_paths' step. +set :shared_paths, [ + 'config/database.yml', + 'config/secrets.yml', + 'log', + 'public/system', + 'public/assets' +] + +# Optional settings: +# set :user, 'foobar' # Username in the server to SSH to. +# set :port, '30000' # SSH port number. + +# This task is the environment that is loaded for most commands, such as +# `mina deploy` or `mina rake`. +task :environment do + # If you're using rbenv, use this to load the rbenv environment. + # Be sure to commit your .rbenv-version to your repository. + # invoke :'rbenv:load' + + # For those using RVM, use this to load an RVM version@gemset. + # invoke :'rvm:use[ruby-1.9.3-p125@default]' +end + +# Put any custom mkdir's in here for when `mina setup` is ran. +# For Rails apps, we'll make some of the shared paths that are shared between +# all releases. +task :setup => :environment do + queue! %[mkdir -p "#{deploy_to}/shared/log"] + queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"] + + queue! %[mkdir -p "#{deploy_to}/shared/config"] + queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"] + + queue! %[touch "#{deploy_to}/shared/config/database.yml"] + queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."] +end + +desc "Deploys the current version to the server." +task :deploy => :environment do + deploy do + # Put things that will set up an empty directory into a fully set-up + # instance of your project. + invoke :'git:clone' + invoke :'deploy:link_shared_paths' + invoke :'bundle:install' + invoke :'rails:db_migrate' + invoke :'rails:assets_precompile' + + to :launch do + queue "mkdir -p #{deploy_to}/current/tmp; touch #{deploy_to}/current/tmp/restart.txt" + end + end +end + +# For help in making your deploy script, see the Mina documentation: +# +# - http://nadarei.co/mina +# - http://nadarei.co/mina/tasks +# - http://nadarei.co/mina/settings +# - http://nadarei.co/mina/helpers + diff --git a/doc/docker/apache2/epp-tester.conf b/doc/docker/apache2/epp-tester.conf index e3a428734..140785385 100644 --- a/doc/docker/apache2/epp-tester.conf +++ b/doc/docker/apache2/epp-tester.conf @@ -5,13 +5,13 @@ Listen 8888 PassengerEnabled on RailsEnv production - DocumentRoot /home/app/epp-tester/public + DocumentRoot /home/app/epp-tester/current/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/registry.conf b/doc/docker/apache2/registry.conf index 938a23602..b01ec745d 100644 --- a/doc/docker/apache2/registry.conf +++ b/doc/docker/apache2/registry.conf @@ -4,13 +4,13 @@ PassengerEnabled on RailsEnv production - DocumentRoot /home/app/registry/public + DocumentRoot /home/app/registry/current/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