Build templates from images in private container registries like AWS ECR, Google Artifact Registry, or any Docker-compatible registry.
AWS ECR
from moru import Template
template = Template().from_aws_registry(
"123456789.dkr.ecr.us-east-1.amazonaws.com/my-image:latest",
access_key_id="AKIA...",
secret_access_key="...",
region="us-east-1"
)
info = Template.build(template, alias="my-ecr-app")
Google Artifact Registry
from moru import Template
import json
# Load service account JSON
with open("service-account.json") as f:
sa_json = json.load(f)
template = Template().from_gcp_registry(
"us-central1-docker.pkg.dev/my-project/my-repo/my-image:latest",
service_account_json=sa_json
)
info = Template.build(template, alias="my-gar-app")
Generic Registry
For any Docker-compatible registry:
from moru import Template
template = Template().from_image(
"registry.example.com/my-image:latest",
username="myuser",
password="mypassword"
)
info = Template.build(template, alias="my-private-app")
Docker Hub Private Images
from moru import Template
template = Template().from_image(
"myorg/private-image:latest",
username="dockerhub_username",
password="dockerhub_token" # Use access token, not password
)
info = Template.build(template, alias="my-dockerhub-app")
GitHub Container Registry
from moru import Template
template = Template().from_image(
"ghcr.io/myorg/my-image:latest",
username="github_username",
password="ghp_..." # GitHub PAT with read:packages scope
)
info = Template.build(template, alias="my-ghcr-app")
Azure Container Registry
from moru import Template
template = Template().from_image(
"myregistry.azurecr.io/my-image:latest",
username="service_principal_id",
password="service_principal_password"
)
info = Template.build(template, alias="my-acr-app")
Extending Registry Images
After pulling from a registry, you can extend the image:
from moru import Template
template = (
Template()
.from_image("myorg/base-image:latest", username="...", password="...")
.pip_install(["additional-package"])
.set_envs({"ENVIRONMENT": "production"})
.set_start_cmd("python app.py", "curl localhost:8080/health")
)
info = Template.build(template, alias="my-extended-app")
Security Best Practices
Never commit credentials to source control. Use environment variables or secret management.
import os
from moru import Template
template = Template().from_image(
os.environ["REGISTRY_IMAGE"],
username=os.environ["REGISTRY_USERNAME"],
password=os.environ["REGISTRY_PASSWORD"]
)
Next Steps