-
Notifications
You must be signed in to change notification settings - Fork 19
Feat: Service deployment with custom OCI image URI flag #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
aa3f93a
f5d7af7
36e783a
8494e06
cc71ec9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ | |
|
|
||
|
|
||
| class ServiceUpdater(object): | ||
| def __init__(self, name, environment, env_sample_file, version=None, | ||
| def __init__(self, name, environment, env_sample_file, version=None, image_uri=None, | ||
| build_args=None, working_dir='.'): | ||
| self.name = name | ||
| self.environment = environment | ||
|
|
@@ -32,37 +32,47 @@ def __init__(self, name, environment, env_sample_file, version=None, | |
| else: | ||
| self.env_sample_file = './env.sample' | ||
| self.version = version | ||
| self.image_uri = image_uri | ||
| self.ecr_client = boto3.session.Session(region_name=self.region).client('ecr') | ||
| self.cluster_name = get_cluster_name(environment) | ||
| self.working_dir = working_dir | ||
| self.build_args = build_args | ||
|
|
||
| def _get_image(self): | ||
| if self.image_uri: | ||
| version = None | ||
| return version, self.image_uri | ||
|
|
||
| def run(self): | ||
| log_warning("Deploying to {self.region}".format(**locals())) | ||
| self.init_stack_info() | ||
| if not os.path.exists(self.env_sample_file): | ||
| raise UnrecoverableException('env.sample not found. Exiting.') | ||
| ecr_client = EcrClient(self.name, self.region, self.build_args) | ||
| ecr_client.set_version(self.version) | ||
| log_intent("name: " + self.name + " | environment: " + | ||
| self.environment + " | version: " + str(ecr_client.version)) | ||
| log_bold("Checking image in ECR") | ||
| ecr_client.build_and_upload_image() | ||
| log_bold("Initiating deployment\n") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this line |
||
| image_url = ecr_client.ecr_image_uri | ||
| image_url += (':' + ecr_client.version) | ||
| return ecr_client.version, image_url | ||
|
|
||
| def run(self): | ||
| log_warning("Deploying to {self.region}".format(**locals())) | ||
| self.init_stack_info() | ||
| if not os.path.exists(self.env_sample_file): | ||
| raise UnrecoverableException('env.sample not found. Exiting.') | ||
|
|
||
| image_version, image_url = self._get_image() | ||
|
|
||
| jobs = [] | ||
| for index, service_name in enumerate(self.ecs_service_names): | ||
| log_bold("Starting to deploy " + service_name) | ||
| color = DEPLOYMENT_COLORS[index % 3] | ||
| image_url = ecr_client.ecr_image_uri | ||
| image_url += (':' + ecr_client.version) | ||
| process = multiprocessing.Process( | ||
| target=deployer.deploy_new_version, | ||
| args=( | ||
| self.region, | ||
| self.cluster_name, | ||
| service_name, | ||
| ecr_client.version, | ||
| image_version, | ||
| self.name, | ||
| self.env_sample_file, | ||
| self.environment, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,13 @@ def _complete_image_url(ecr_client: EcrClient): | |
|
|
||
|
|
||
| class TaskDefinitionCreator: | ||
| def __init__(self, name, environment, version, build_args, region='ap-south-1'): | ||
| def __init__(self, name, environment, version, image_uri, build_args, region='ap-south-1'): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it should not have been there. pushed the wrong changes. |
||
| self.name = name | ||
| self.environment = environment | ||
| self.build_args = build_args | ||
| self.region = region | ||
| self.version = version | ||
| self.image_uri = image_uri | ||
| self.client = get_client_for('iam', self.environment) | ||
| self.resource = get_resource_for('iam', self.environment) | ||
| self.env_sample_file = './env.sample' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jagriti-simpl Add a descriptive help message