Class: DockerRailsAppCreator
Constant Summary
collapse
- ARCHIVE_TMP_FILE =
"/tmp/rails_application.tar.gz"
DockerImageCreator::DAEMON_OPTIONS, DockerImageCreator::DOCKER_DIR, DockerImageCreator::INTERACT_OPTIONS, DockerImageCreator::REMOVE_INTERMEDIATE_FLAG
Instance Attribute Summary
#definition, #docker_host, #docker_host_secure, #image_name_forced, #use_date_as_version, #version_forced
Instance Method Summary
collapse
#add_it, #api_image, #build_it, #copy_image_support_to_stage, #delete_image_support_from_stage, #do_push, #do_tag, #docker_api, #image_name, #initialize, #kill_all, #openlogic_home, #push_it, #run_it, #run_with_extension, #subtract, #tag_it, #use_date_as_version?, #version
Instance Method Details
#after_build(definiton) ⇒ Object
52
53
54
55
56
57
|
# File 'lib/support/docker_rails_app_creator.rb', line 52
def after_build(definiton)
if (build_source == :current)
stage_files_dir = docker_dir() + "/files"
FileUtils.rm_f stage_files_dir
end
end
|
#before_build(definition) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/support/docker_rails_app_creator.rb', line 11
def before_build(definition)
build_from_current_dir = true
stage_files_dir = docker_dir() + "/files"
FileUtils.rm_rf stage_files_dir
FileUtils.mkdir_p stage_files_dir
archive_file = ARCHIVE_TMP_FILE
`rm -rf #{archive_file}`
`tar -czf #{archive_file} --exclude=tmp/* --exclude .git --exclude "*.log" *`
FileUtils.mv(archive_file, stage_files_dir)
create_database_config_file(definition, stage_files_dir)
end
|
#create_database_config_file(definition, directory) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/support/docker_rails_app_creator.rb', line 25
def create_database_config_file(definition, directory)
db_host_name = definition['run']['name'] + "-db"
File.open("#{directory}/database.yml", "w") do |file|
content = "
#This file generated by Docker Rails when building docker image
production:
adapter: mysql2
database: application_db
pool: 5
timeout: 5000
host: #{db_host_name}
port: 3306
user: root
password: password
persistence: :db
"
file.write(content)
end
end
|
#docker_dir ⇒ Object
7
8
9
|
# File 'lib/support/docker_rails_app_creator.rb', line 7
def docker_dir
dir = definition['build']['docker_dir'] || "#{FileUtils.pwd}/docker"
end
|
#prepare_for_git_pull ⇒ Object
45
46
47
48
49
50
|
# File 'lib/support/docker_rails_app_creator.rb', line 45
def prepare_for_git_pull
ssh_staging_dir = stage_files_dir + "/ssh/"
FileUtils.mkdir_p ssh_staging_dir
FileUtils.cp "#{ENV['HOME']}/.ssh/id_rsa", ssh_staging_dir
FileUtils.cp "#{ENV['HOME']}/.ssh/id_rsa.pub", ssh_staging_dir
end
|