registry = containerregistry.Registry("registry", resource_group_name=resource_group.name, sku=containerregistry.SkuArgs(name="Basic"), admin_user_enabled=True) credentials = pulumi.Output.all(resource_group.name, registry.name).apply( lambda args: containerregistry.list_registry_credentials(resource_group_name=args[0], registry_name=args[1])) admin_username = credentials.username admin_password = credentials.passwords[0]["value"] custom_image = "node-app" my_image = docker.Image(custom_image, image_name=registry.login_server.apply( lambda login_server: f"{login_server}/{custom_image}:v1.0.0"), build=docker.DockerBuild(context=f"./{custom_image}"), registry=docker.ImageRegistry( server=registry.login_server, username=admin_username, password=admin_password)) container_app = web.ContainerApp("app", resource_group_name=resource_group.name, kube_environment_id=kube_env.id, configuration=web.ConfigurationArgs( ingress=web.IngressArgs( external=True, target_port=80 ), registries=[ web.RegistryCredentialsArgs(
if len(parts) != 2: raise Exception("Invalid credentials") return docker.ImageRegistry(creds.proxy_endpoint, parts[0], parts[1]) # Create a private ECR registry. repo = aws.ecr.Repository(image_name, name=image_name) registry = repo.registry_id.apply(get_registry_info) image_tag = repo.repository_url.apply(lambda url: url + ":latest") # Build and publish the image. build_image = docker.Image( image_name, build=docker.DockerBuild(context='app'), image_name=image_tag, registry=registry, # opts=ResourceOptions(aliases="hw_image") ) # Deployment based on simpledeployment helloworldapp = SimpleDeployment( "helloworld", replicas=2, image=image_tag, ports=[80], envvars=[{ "name": "MESSAGE", "value": message }],
import base64 import pulumi import pulumi_aws as aws import pulumi_docker as docker from pulumi_aws import ecr def get_registry_info(rid): creds = aws.ecr.get_credentials(rid) decoded = base64.b64decode(creds.authorization_token).decode() parts = decoded.split(':') if len(parts) != 2: raise Exception("Invalid credentials") return docker.ImageRegistry(creds.proxy_endpoint, parts[0], parts[1]) repository = ecr.Repository("test-repository", name="test-repository") registry = repository.registry_id.apply(get_registry_info) image = docker.Image( 'my-image', build=docker.DockerBuild(context='.', args={}), image_name=repository.repository_url.apply(lambda url: url + ':latest'), registry=registry)
import base64 from pulumi_aws import ecr import pulumi_docker as docker import pulumi app = 'my-app' # Create repository repo = ecr.Repository(app) def create_image_registry(rid): creds = ecr.get_credentials(rid) decoded = base64.b64decode(creds.authorization_token).decode('utf-8') username, password = decoded.split(':') return docker.ImageRegistry(creds.proxy_endpoint, username, password) # Get credentials and create an ImageRegistry from that registry = repo.registry_id.apply(lambda rid: create_image_registry(rid)) # Create image image = docker.Image(app, image_name=pulumi.Output.concat(repo.repository_url, ':', '1.0.0'), build=docker.DockerBuild(context=f'./{app}'), registry=registry)
import pulumi import pulumi_docker as docker import pulumi_github as github env = pulumi.get_stack() my_image = docker.Image( name="my-nginx", image_name="pulumi-demo:0.0.1", build=docker.DockerBuild( dockerfile="Dockerfile" ), skip_push=True, ) # pulumi.export('IMAGE', my_image) # image_to_use = docker.RemoteImage("my-nginx", # name="pulumi-demo:0.0.1", # keep_locally=True # ) container = docker.Container("my-nginx", name="my-nginx", image=my_image.base_image_name, ports=[{"internal":80, "external":80}] ) # pulumi.export('CONTAINER', container) repo = pulumi.StackReference('aldenso/github_example/'+env)
import base64 import pulumi_aws as aws import pulumi_docker as docker import pulumi # Get registry info (creds and endpoint) so we can build/publish to it. def get_registry_info(rid): creds = aws.ecr.get_credentials(registry_id=rid) decoded = base64.b64decode(creds.authorization_token).decode() parts = decoded.split(':') if len(parts) != 2: raise Exception("Invalid credentials") return docker.ImageRegistry(creds.proxy_endpoint, parts[0], parts[1]) for i in range(3): # Create a private ECR registry. repo = aws.ecr.Repository('my-repo-%i' % i) registry = repo.registry_id.apply(get_registry_info) # Build and publish the image. docker.Image( 'my-image-%i' % i, build=docker.DockerBuild(context='app', args={'parameter': str(i)}), image_name=repo.repository_url, registry=registry, )
redis_image = docker.RemoteImage("redis_image", name="redis:6.2", keep_locally=True) redis_container = docker.Container( "redis_container", image=redis_image.latest, ports=[docker.ContainerPortArgs(internal=redis_port, external=redis_port)], networks_advanced=[ docker.ContainerNetworksAdvancedArgs(name=network.name, aliases=[redis_host]) ]) app_image = docker.Image("app_image", build=docker.DockerBuild(context="./app"), image_name="app", skip_push=True) app_port = 5000 app_container = docker.Container( "app_container", image=app_image.base_image_name, ports=[docker.ContainerPortArgs(internal=app_port, external=app_port)], envs=[f"REDIS_HOST={redis_host}", f"REDIS_PORT={redis_port}"], networks_advanced=[ docker.ContainerNetworksAdvancedArgs(name=network.name) ], opts=pulumi.ResourceOptions(depends_on=[redis_container]))
"""An Azure Python Pulumi program""" import pulumi from pulumi_azure import core, containerservice import pulumi_docker # Create an Azure Resource Group resource_group = core.ResourceGroup('miw_20200729') # Create registry registry = containerservice.Registry('registry', admin_enabled=True, sku='Basic', resource_group_name=resource_group.name) # ImageRegistry r = pulumi.Output.all( registry.login_server, registry.admin_username, registry.admin_password).apply( lambda a: pulumi_docker.ImageRegistry(a[0], a[1], a[2])) # Build and publish image image = pulumi_docker.Image( "my-app", image_name=registry.login_server.apply(lambda s: f'{s}/my-app:v1.0.0'), build=pulumi_docker.DockerBuild(context='./my-app'), registry=r)