in scripts/gen_dockerfile.py [0:0]
def generate_dockerfile_command(base_image, config_file, source_dir):
"""Write a Dockerfile and helper files for an application.
Args:
base_image (str): Docker image name to build on top of
config_file (str): Path to user's app.yaml (might be <service>.yaml)
source_dir (str): Directory container user's source code
"""
# Read yaml file. Does not currently support multiple services
# with configuration filenames besides app.yaml
with io.open(config_file, 'r', encoding='utf8') as yaml_config_file:
raw_config = yaml.safe_load(yaml_config_file)
# Determine complete configuration
app_config = get_app_config(raw_config, base_image, config_file,
source_dir)
# Generate list of filenames and their textual contents
files = generate_files(app_config)
# Write files
for filename, contents in files.items():
full_filename = os.path.join(source_dir, filename)
with io.open(full_filename, 'w', encoding='utf8') as outfile:
outfile.write(contents)