Class: PicsolveDockerBuilder::NodeJs
- Inherits:
-
Frame
- Object
- Frame
- PicsolveDockerBuilder::NodeJs
show all
- Defined in:
- lib/picsolve_docker_builder/nodejs.rb
Overview
Instance Method Summary
collapse
Methods inherited from Frame
#asset_image, #asset_image_build, #asset_image_dockerfile, #build, #build_dir, #build_mode, #build_user, #build_user_home, #build_user_uid, #container, #create_container, #create_logger, #dest_image_name, #docker_build_build, #dockerfile, #dockerfile_exists?, #dockerfile_hooks_asset_build_early, #dockerfile_hooks_asset_build_late, #dockerfile_hooks_docker_build_early, #dockerfile_hooks_docker_build_late, #dockerfile_path, #dockerfile_template, #dockerignore_template, #environment, #execute, #execute_attach, #fetch_asset_image, #image_name, #initialize, #jenkins_build_number, #log, #push, #runtime_image_name, #ssh_auth_forwarding?, #ssh_auth_forwarding_dockerfile, #ssh_auth_forwarding_path, #ssh_known_hosts, #start, #stop, #tag, #tags, #validate_config, #validate_config_docker, #volume_ssh_auth_forwarding, #volume_workspace, #volumes, #volumes_array
Methods included from Base
#base_dir, #config, #config_file, #config_path, #config_paths, #create_logger, #log, #read_config, #validate_config
Instance Method Details
#asset_build ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 111
def asset_build
log.info "start asset building with image #{image_name}"
start
prepare_volumes
build_cmd = [
'gosu', build_user, 'bash', '-c', asset_build_command
]
execute_attach build_cmd
log.info "finished asset building with image #{image_name}"
stop
end
|
#asset_build_command ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 98
def asset_build_command
runs = config['nodejs']['build_commands'].map do |tasks|
"#{tasks}"
end
runs = [
'export LANG=en_US.UTF-8',
'export LANGUAGE=en_US.UTF-8',
'export LC_ALL=en_US.UTF-8',
"export PATH=$PATH:#{File.join(build_dir, '/node_modules/.bin')}"
] + runs
runs.join ' && '
end
|
#default_config ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 14
def default_config
c = super
c['nodejs'] = {
'build_commands' => [
'npm install',
'grunt jenkins'
]
}
c
end
|
#docker_build ⇒ Object
94
95
96
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 94
def docker_build
@docker_build = docker_builder.build
end
|
#docker_build_files ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 34
def docker_build_files
f = []
f << Builder::File.new(
'dist.tar.gz',
source: File.join(base_dir, 'dist.tar.gz'),
destination: '/var/www/html'
)
begin
add_files = config['docker']['docker_build']['add_files']
rescue NoMethodError
add_files = []
end
add_files.each do |file|
f << Builder::File.new(
file,
source: File.join(base_dir, file)
)
end
f
end
|
#docker_builder ⇒ Object
85
86
87
88
89
90
91
92
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 85
def docker_builder
Builder::Builder.new(
base_image: runtime_image_name,
maintainer: 'Picsolve Onlineops <[email protected]>',
files: docker_build_files,
hooks: docker_builder_hooks
)
end
|
#docker_builder_hooks ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 58
def docker_builder_hooks
begin
hooks = config['docker']['dockerfile_hooks']['docker_build']
hooks.keys.each do |key|
begin
key_sym = key.to_sym
rescue
key_sym = key
end
hooks[key_sym || key] = hooks.delete(key)
end
rescue NoMethodError
hooks = {}
end
hooks[:before_adds] = [
'# remove existing /var/www/html',
'RUN rm -rf /var/www/html'
]
hooks[:after_adds] = [
'# ensure rights',
'RUN chown -R root:www-data /var/www/html'
]
hooks
end
|
#output_dir ⇒ Object
10
11
12
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 10
def output_dir
config['nodejs']['output_dir']
end
|
#prepare_volumes ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/picsolve_docker_builder/nodejs.rb', line 25
def prepare_volumes
execute [
'chown',
'-c',
build_user,
build_user_home
]
end
|