def main(args): config = Config() with repository_root(): with use_dir(Projects.BACKEND): log.info(f"Updating {args.environment} backend") run(["zappa", "update", args.environment]) log.info(f"Running migrations for {args.environment}") run(["zappa", "manage", args.environment, "migrate"]) with use_dir(Projects.FRONTEND): log.info(f"Updating {args.environment} frontend") run(["eb", "deploy", f"{config.name}-{args.environment}"])
def main(args): config = Config() ecs = boto3.client("ecs") with repository_root(): with use_dir(Projects.BACKEND): log.info(f"Updating {args.environment} backend") run(["zappa", "update", args.environment]) log.info(f"Running migrations for {args.environment}") run(["zappa", "manage", args.environment, "migrate"]) with use_dir(Projects.FRONTEND): log.info("Building frontend") image_name = f"{config.name}-frontend" latest = f"{image_name}:latest" git_commit_hash = get_git_commit_hash() tags = ["latest", f"{args.environment}", f"{git_commit_hash}"] run([ "docker", "build", "-t", f"{latest}", "-t", f"{image_name}:{args.environment}", "-t", f"{image_name}:{git_commit_hash}", ".", ]) for tag in tags: run([ "docker", "tag", f"{image_name}:{tag}", f"{ECR_REPO_PREFIX}/{image_name}:{tag}", ]) run([ "docker", "push", f"{ECR_REPO_PREFIX}/{image_name}:{tag}" ]) log.info( f"Updating service frontend-{args.environment} on {config.name} ECS cluster" ) ecs.update_service( cluster=f"{config.name}", service=f"frontend-{args.environment}", taskDefinition=f"{config.name}-frontend-{args.environment}", forceNewDeployment=True, )
def _run_self(self, phase, force_create=False): phase_func = getattr(self, phase, None) is_create = phase == Phases.CREATE styled_name = style(self.identifier, bold=True, fg='cyan') if phase_func is not None: with repository_root(): if not is_create and not self.installed: log.warning(f'Component {styled_name} is not installed, skipping') return if is_create and self.installed and not force_create: log.warning(f'Component {styled_name} is already installed, skipping') return log.debug(self._log_string.format(phase, self.__class__.__name__)) phase_func()
def call_phase(self, phase): """ Calls a phase (e.g. create, update, delete) on self + all sub components """ if self.exclude: log.debug( f'Skipping {self.identifier} as it was found in the exclude list' ) return log_string = 'Calling phase {} for {}' phase_func = getattr(self, phase, None) if phase_func is not None: with repository_root(): log.info(log_string.format(phase, self.__class__.__name__)) phase_func() for component in self.sub_components: log.info(log_string.format(phase, component.__class__.__name__)) component.call_phase(phase)
def main(args): config = Config() with repository_root(): with use_dir(Projects.BACKEND): log.info(f"Updating {args.environment} backend") run(["zappa", "update", args.environment]) log.info(f"Running migrations for {args.environment}") run(["zappa", "manage", args.environment, "migrate"]) with use_dir(Projects.FRONTEND): log.info("Building frontend") image_name = f"{config.name}-frontend" latest = f"{image_name}:latest" run(["docker", "build", "-t", f"{image_name}", "."]) run([ "docker", "tag", f"{config.name}-frontend:latest", f"{ECR_REPO_PREFIX}/{latest}", ]) run(["docker", "push", f"{ECR_REPO_PREFIX}/{latest}"])
def dump(self, data): with repository_root(): with open(self.settings_file_path, "w") as f: f.write(data.dumps())
def parse(self): with repository_root(): with open(self.settings_file_path) as f: return RedBaron(f.read())
def dump(self, data): with repository_root(): with open( os.path.join(Projects.BACKEND, Projects.BACKEND, file_name), 'w') as f: f.write(data.dumps())
def parse(self): with repository_root(): with open( os.path.join(Projects.BACKEND, Projects.BACKEND, file_name)) as f: return RedBaron(f.read())