Skip to content

Commit

Permalink
Merge pull request #7 from yahoo/docker_fixes
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
dwighthubbard authored May 29, 2018
2 parents a10402e + ccaeacc commit 8976677
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
3 changes: 1 addition & 2 deletions invirtualenv_plugins/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
DOCKERFILE_TEMPLATE = """FROM {{docker_container['base_image']|default('ubuntu:17.10')}}
COPY docker_build.sh /tmp/docker_build.sh
COPY deploy.conf /var/lib/invirtualenv/deploy.conf
{% if docker_container['setenv'] %}# Environment Settings
{% for setting, value in docker_container['setenv'].items() %}ENV {{setting}} {{value}}
{% endfor %}{% endif %}{% if docker_container['files'] %}
Expand Down Expand Up @@ -92,8 +93,6 @@ def run_package_command(self, package_hashes, wheel_dir='wheels'):

logger.debug('Dockerfile')
logger.debug(self.render_template_with_config())
logger.debug('Wheels')
logger.debug(os.listdir(wheel_dir))
with open('Dockerfile', 'w') as dockerfile_handle:
dockerfile_handle.write(self.render_template_with_config())
container_tag = '{name}:{version}'.format(name=self.config['docker_container']['container_name'], version=self.config['global']['version'])
Expand Down
26 changes: 26 additions & 0 deletions invirtualenv_plugins/parsedconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import logging
from invirtualenv.config import generate_parsed_config_file
from invirtualenv.plugin_base import InvirtualenvPlugin


logger = logging.getLogger(__name__)


class InvirtualenvParsedConfig(InvirtualenvPlugin):
package_formats = ['parsed_deploy_conf']
default_config_filename = 'deploy.conf.parsed'

def __init__(self, *args, **kwargs):
super(InvirtualenvParsedConfig, self).__init__(*args, **kwargs)
with open(self.config_file) as config_file_handle:
self.package_template = config_file_handle.read()
logger.debug('Read template %r', self.package_template)

def run_package_command(self, package_hashes, wheel_dir='wheels'):
logger.debug('Config')
logger.debug(self.config)
logger.debug('Deploy.conf')
logger.debug(open('deploy.conf').read())
generate_parsed_config_file('deploy.conf', self.default_config_filename)
return self.default_config_filename

5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
console_scripts =
invirtualenv=invirtualenv.cli:main
invirtualenv.plugin =
docker = invirtualenv_plugins.docker:InvirtualenvDocker
rpm = invirtualenv_plugins.rpm:InvirtualenvRPM
docker = invirtualenv_plugins.docker:InvirtualenvDocker
parsedconfig = invirtualenv_plugins.parsedconfig:InvirtualenvParsedConfig
rpm = invirtualenv_plugins.rpm:InvirtualenvRPM
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def get_version(version_file):
'invirtualenv.plugin': [
'docker=invirtualenv_plugins.docker:InvirtualenvDocker',
'rpm=invirtualenv_plugins.rpm:InvirtualenvRPM',
'parsedconfig=invirtualenv_plugins.parsedconfig:InvirtualenvParsedConfig',
],
},
install_requires=[
Expand Down

0 comments on commit 8976677

Please sign in to comment.