This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
/
drivers_framework_hanami.rb
59 lines (50 loc) · 1.67 KB
/
drivers_framework_hanami.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true
module Drivers
module Framework
class Hanami < Drivers::Framework::Base
adapter :hanami
allowed_engines :hanami
output filter: [
:migrate, :migration_command, :deploy_environment, :assets_precompile, :assets_precompilation_command
]
def raw_out
assets_command = node['deploy'][app['shortname']]['framework']['assets_precompilation_command'] ||
'/usr/local/bin/bundle exec hanami assets precompile'
migration_command = node['deploy'][app['shortname']]['framework']['migration_command'] ||
'/usr/local/bin/bundle exec hanami db migrate'
super.merge(
deploy_environment:
{ 'HANAMI_ENV' => deploy_env, 'DATABASE_URL' => database_url },
assets_precompilation_command: assets_command,
migration_command: migration_command
)
end
def configure
build_env
end
def deploy_before_restart
link_env
super
end
private
def build_env
deploy_to = deploy_dir(app)
env = environment
context.template File.join(deploy_to, 'shared', 'config', ".env.#{deploy_env}") do
owner node['deployer']['user']
group www_group
source 'dot_env.erb'
variables environment: env
end
end
def link_env
deploy_to = deploy_dir(app)
env_name = deploy_env
context.link File.join(deploy_to, 'current', ".env.#{env_name}") do
to File.join(deploy_to, 'shared', 'config', ".env.#{env_name}")
ignore_failure true
end
end
end
end
end