diff --git a/Gemfile b/Gemfile index c625661..1a7faff 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,7 @@ end group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri mingw x64_mingw ] + gem "mina" end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 01a8675..00790de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,6 @@ -PATH - remote: ../merged +GIT + remote: https://github.com/HubFeenixMakers/merged + revision: 658efe8e53651707957260a6d96ed8527b352e10 specs: merged (0.1.0) git @@ -152,6 +153,9 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) + mina (1.2.4) + open4 (~> 1.3.4) + rake mini_mime (1.1.2) minitest (5.16.3) msgpack (1.6.0) @@ -170,6 +174,7 @@ GEM notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) + open4 (1.3.4) passenger (6.0.15) rack rake (>= 0.8.1) @@ -291,6 +296,7 @@ DEPENDENCIES haml-rails importmap-rails merged! + mina passenger pg (~> 1.1) puma (~> 5.0) diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..5eec031 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,77 @@ +require 'mina/rails' +require 'mina/git' +require 'mina/rbenv' # for rbenv support. (https://rbenv.org) + +# 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 :application_name, 'staging' +set :domain, '192.168.129.10' +set :deploy_to, '/home/feenix/staging' +set :repository, "https://github.com/HubFeenixMakers/hubfeenix.fi.git" +set :branch, 'main' + +# Optional settings: +set :user, 'feenix' # Username in the server to SSH to. +# set :port, '30000' # SSH port number. +# set :forward_agent, true # SSH forward_agent. + +# Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step. +# Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more +# run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files` +set :shared_dirs, fetch(:shared_dirs, []).push('tmp/pids' , 'tmp/sockets') +set :shared_files, fetch(:shared_files, []).push('config/master.key') + +# This task is the environment that is loaded for all remote run commands, such as +# `mina deploy` or `mina rake`. +task :remote_environment do + # If you're using rbenv, use this to load the rbenv environment. + # Be sure to commit your .ruby-version or .rbenv-version to your repository. + invoke :'rbenv:load' + +end + +# Put any custom commands you need to run at setup +# All paths in `shared_dirs` and `shared_paths` will be created on their own. +task :setup do + # command %{rbenv install 2.5.3 --skip-existing} + # command %{rvm install ruby-2.5.3} + # command %{gem install bundler} +end + +desc "Deploys the current version to the server." +task :deploy do + # uncomment this line to make sure you pushed your local branch to the remote origin + # invoke :'git:ensure_pushed' + 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:assets_precompile' + invoke :'deploy:cleanup' + + on :launch do + in_path(fetch(:current_path)) do + invoke :'passenger:restart' + end + end + end + + # you can use `run :local` to run tasks on local machine before of after the deploy scripts + # run(:local){ say 'done' } +end + +namespace :passenger do + desc "Restart Passenger" + task :restart do + command %{ + echo "-----> Restarting passenger" + #{echo_cmd %[touch tmp/restart.txt]} + } + end +end