Deploy akkounts without the application_git cookbook
Use the built-in git resource from Chef instead. poise/application does not work on modern Chef.
This commit is contained in:
@@ -5,15 +5,13 @@ license 'MIT'
|
||||
description 'Installs/configures kosmos-akkounts'
|
||||
long_description 'Installs/configures kosmos-akkounts'
|
||||
version '0.2.0'
|
||||
chef_version '>= 14.0'
|
||||
chef_version '>= 18.0'
|
||||
|
||||
depends 'kosmos-nginx'
|
||||
depends "kosmos-nodejs"
|
||||
depends "redisio"
|
||||
depends "poise-ruby-build"
|
||||
depends "application"
|
||||
depends 'application_git'
|
||||
depends "postgresql"
|
||||
depends "kosmos_postgresql"
|
||||
depends "backup"
|
||||
depends "kosmos-dirsrv"
|
||||
depends "ruby_build"
|
||||
|
||||
@@ -30,9 +30,15 @@ npm_package "yarn" do
|
||||
end
|
||||
|
||||
ruby_version = "2.7.5"
|
||||
bundle_path = "/opt/ruby_build/builds/#{ruby_version}/bin/bundle"
|
||||
ruby_path = "/opt/ruby_build/builds/#{ruby_version}"
|
||||
bundle_path = "#{ruby_path}/bin/bundle"
|
||||
rails_env = node.chef_environment == "development" ? "development" : "production"
|
||||
|
||||
ruby_build_install 'v20230615'
|
||||
ruby_build_definition ruby_version do
|
||||
prefix_path ruby_path
|
||||
end
|
||||
|
||||
postgres_readonly_host = search(:node, "role:postgresql_replica").first["knife_zero"]["host"] rescue nil
|
||||
btcpay_host = search(:node, "role:btcpay").first["knife_zero"]["host"] rescue nil
|
||||
lndhub_host = search(:node, "role:lndhub").first["knife_zero"]["host"] rescue nil
|
||||
@@ -152,7 +158,7 @@ systemd_unit "akkounts-sidekiq.service" do
|
||||
User: deploy_user,
|
||||
WorkingDirectory: deploy_path,
|
||||
Environment: "MALLOC_ARENA_MAX=2",
|
||||
ExecStart: "#{bundle_path} exec sidekiq -C #{deploy_path}/config/sidekiq.yml -e production",
|
||||
ExecStart: "#{bundle_path} exec sidekiq -C #{deploy_path}/config/sidekiq.yml -e #{rails_env}",
|
||||
WatchdogSec: "10",
|
||||
Restart: "on-failure",
|
||||
RestartSec: "1",
|
||||
@@ -169,84 +175,83 @@ systemd_unit "akkounts-sidekiq.service" do
|
||||
action [:create, :enable]
|
||||
end
|
||||
|
||||
application deploy_path do
|
||||
deploy_env = {
|
||||
"HOME" => deploy_path,
|
||||
"PATH" => "#{ruby_path}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
|
||||
"RAILS_ENV" => rails_env,
|
||||
"NODE_ENV" => rails_env
|
||||
}
|
||||
|
||||
git deploy_path do
|
||||
repository node[app_name]["repo"]
|
||||
revision node[app_name]["revision"]
|
||||
user deploy_user
|
||||
group deploy_group
|
||||
# Restart services on deployments
|
||||
notifies :run, "execute[restart #{app_name} services]", :delayed
|
||||
end
|
||||
|
||||
execute "restart #{app_name} services" do
|
||||
command "true"
|
||||
action :nothing
|
||||
notifies :restart, "service[#{app_name}]", :delayed
|
||||
notifies :restart, "service[#{app_name}-sidekiq]", :delayed
|
||||
end
|
||||
|
||||
file "#{deploy_path}/config/master.key" do
|
||||
content credentials['rails_master_key']
|
||||
mode '0400'
|
||||
owner deploy_user
|
||||
group deploy_group
|
||||
notifies :run, "execute[restart #{app_name} services]", :delayed
|
||||
end
|
||||
|
||||
# Take care of application restarts manually, in the git resource
|
||||
action_on_update false
|
||||
template "#{deploy_path}/.env.#{rails_env}" do
|
||||
source 'env.erb'
|
||||
owner deploy_user
|
||||
group deploy_group
|
||||
mode 0600
|
||||
sensitive true
|
||||
variables config: env
|
||||
notifies :run, "execute[restart #{app_name} services]", :delayed
|
||||
end
|
||||
|
||||
environment "HOME" => deploy_path,
|
||||
"PATH" => "/opt/ruby_build/builds/#{ruby_version}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
|
||||
execute "bundle install" do
|
||||
environment deploy_env
|
||||
user deploy_user
|
||||
cwd deploy_path
|
||||
command "bundle install --without development,test --deployment"
|
||||
end
|
||||
|
||||
ruby_runtime ruby_version do
|
||||
provider :ruby_build
|
||||
version ruby_version
|
||||
end
|
||||
execute "yarn install" do
|
||||
environment deploy_env
|
||||
user deploy_user
|
||||
cwd deploy_path
|
||||
command "yarn install --pure-lockfile"
|
||||
end
|
||||
|
||||
git do
|
||||
user deploy_user
|
||||
group deploy_group
|
||||
repository node[app_name]["repo"]
|
||||
revision node[app_name]["revision"]
|
||||
# Restart services on deployments
|
||||
notifies :restart, "application[#{deploy_path}]", :delayed
|
||||
end
|
||||
execute 'rake db:migrate' do
|
||||
environment deploy_env
|
||||
user deploy_user
|
||||
group deploy_group
|
||||
cwd deploy_path
|
||||
command "bundle exec rake db:migrate"
|
||||
end
|
||||
|
||||
file "#{deploy_path}/config/master.key" do
|
||||
content credentials['rails_master_key']
|
||||
mode '0400'
|
||||
owner deploy_user
|
||||
group deploy_group
|
||||
end
|
||||
execute 'rake assets:precompile' do
|
||||
environment deploy_env
|
||||
user deploy_user
|
||||
group deploy_group
|
||||
cwd deploy_path
|
||||
command "bundle exec rake assets:precompile"
|
||||
end
|
||||
|
||||
template "#{deploy_path}/.env.production" do
|
||||
source 'env.production.erb'
|
||||
owner deploy_user
|
||||
group deploy_group
|
||||
mode 0600
|
||||
sensitive true
|
||||
variables config: env
|
||||
notifies :restart, "application[#{deploy_path}]", :delayed
|
||||
end
|
||||
service "akkounts" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
execute "bundle install" do
|
||||
environment "HOME" => deploy_path
|
||||
user deploy_user
|
||||
cwd deploy_path
|
||||
command "/opt/ruby_build/builds/#{ruby_version}/bin/bundle install --without development,test --deployment"
|
||||
end
|
||||
|
||||
execute "yarn install" do
|
||||
environment "HOME" => deploy_path, "NODE_ENV" => "production"
|
||||
user deploy_user
|
||||
cwd deploy_path
|
||||
command "yarn install --pure-lockfile"
|
||||
end
|
||||
|
||||
execute 'rake db:migrate' do
|
||||
environment "RAILS_ENV" => rails_env, "HOME" => deploy_path
|
||||
user deploy_user
|
||||
group deploy_group
|
||||
cwd deploy_path
|
||||
command "PATH=\"/opt/ruby_build/builds/#{ruby_version}/bin:$PATH\" bundle exec rake db:migrate"
|
||||
end
|
||||
|
||||
execute 'rake assets:precompile' do
|
||||
environment "RAILS_ENV" => rails_env, "HOME" => deploy_path
|
||||
user deploy_user
|
||||
group deploy_group
|
||||
cwd deploy_path
|
||||
command "PATH=\"/opt/ruby_build/builds/#{ruby_version}/bin:$PATH\" bundle exec rake assets:precompile"
|
||||
end
|
||||
|
||||
service "akkounts" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
service "akkounts-sidekiq" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
service "akkounts-sidekiq" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
firewall_rule "akkounts_zerotier" do
|
||||
|
||||
Reference in New Issue
Block a user