Custom image

Instructions to use a custom docker image

To use your own custom docker image, you can set image: AUTO in your service module.

name: hello
  - name: staging
    path: "opta.yaml"
  - name: hello
    type: k8s-service
      http: 80
    image: AUTO
    healthcheck_path: "/"
    public_uri: "/hello"

For this example, we will make a simple change to our hello application (also available on github).

from flask import Flask
app = Flask(__name__)
def hello_world():
    return "<p>Hello, World! v2</p>"
FROM python:3.8-slim-buster


WORKDIR /app RUN pip install Flask==0.12 COPY . /app ENV PORT 80 CMD python3 -m flask run --host= --port=${PORT}

Build the image locally:

docker build . -t hello-app:v2

Deploy the new image to the kubernetes cluster:

opta deploy --image hello-app:v2

This will:

  1. Push the image to the private container registry (ECR, GCR, ACR) - this registry is created during environment creation.
  2. Update the kubernetes deployment to use the new container image.
  3. Create new pods to use the new container image - automatically done by kubernetes.

No need to manually manage the repositories!

Note: If you deploy an Image with an already existing tag image, Opta would still detect those changes and make sure the image is deployed again.