Extra Horizon
GitHub
  • Extra Horizon Documentation
  • Getting Started
    • Start familiarizing yourself
  • Tutorials
    • Medical Device Tutorial
      • Preparation
      • Build your first prototype
        • Define a data model
        • Configure your workflows
          • Workflow 1: Analyze a measurement
          • Workflow 2: Create & store a PDF report
          • Workflow 3: Send an e-mail
        • Define your permissions
          • Update your schema with user permissions
          • Update your schema with group permissions
        • Build the Front-End
          • Set up oAuth in your backend
          • Demo login page
      • Summary & Wrap up
    • Polysomnography (PSG) Tutorial
    • Retool - Building dashboards Tutorial
  • FAQ
    • General
  • Services
    • Identity and Access Management
      • User service
        • Users
        • Groups
        • Global roles
        • Configuration
      • Auth Service
        • Applications
        • OAuth2
        • OAuth1
        • MFA
        • OpenID Connect
          • Google Cloud
          • Azure ADFS
    • Data Management
      • File Service
      • Data Service
        • Schemas
        • Documents
        • FAQ Data Service
    • Automation
      • Task Service
        • Functions
        • Tasks
        • API Functions
        • Examples
          • Hello world (JS)
          • Hello world (Py)
          • Hello world (Docker)
        • FAQ
      • Dispatchers Service
      • Event Service
        • System Events
    • Communication
      • Notification Service
        • Notifications
        • Settings
      • Mail Service
    • Other
      • Localization Service
        • Language Codes
      • Template Service
        • Localizations
      • Payments Service
        • Subscriptions
        • Stripe
        • iOS App Store
      • Configurations Service
  • API Reference
    • OpenAPI Specifications
    • 📦Changelog
      • Per-service Changelog
    • Postman Reference Collection
  • Tools
    • SDK
    • CLI
    • Control Center
  • Additional Resources
    • Resource Query Language (RQL)
    • Handling Errors
    • GitHub
    • API interaction (Python)
    • Migration guide: Enabling verification request limiting
  • ExH Platform
    • 🙋Support
    • ⏱️Usage and Performance
    • 🔓Security
    • 🗺️Regions
    • ⚖️Cloud Subscription Agreement
    • 🇺🇸CFR 21 Part 11
Powered by GitBook
On this page
  • Building the docker image
  • Gaining access to the docker registry
  • Sending the docker image to the register
  • Running the task
  • Important

Was this helpful?

  1. Services
  2. Automation
  3. Task Service
  4. Examples

Hello world (Docker)

Hello world docker tutorial for Extra Horizon task functions

PreviousHello world (Py)NextFAQ

Last updated 1 year ago

Was this helpful?

In this simple tutorial we will show you how you can build task functions using docker. First we need to create a folder with the following files:

  • A app.py file that will contain our hello-world code

  • A Dockerfile to build our container

app.py
def handler(event, context):
    print("Hello world!")

We will create a handler function that will act as the entrypoint of your task.

Dockerfile
FROM public.ecr.aws/lambda/python:3.9

# Copy function code
COPY app.py ${LAMBDA_TASK_ROOT}

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.handler" ]

Extra Horizon Task Functions are based on AWS Lambda. Because of this we need to make sure our container is based on a lambda container image (You can finder all the different images available on ).

Next we make sure that when we build our image our app.py code is copied to the container.

Finally we need to make sure our handler function is triggered when we start our container. We can do this by passing "app.handler" as a command parameter.

Building the docker image

You can build the example docker image as follows:

docker build -t <registry-url>/<image-name>:<your-tag> .

Please replace <your-tag> by whatever tag you choose to give the image. This tag is important because later on we need to tell the task which docker image to use and having a friendly name is definitely easier than a long hash :)

Gaining access to the docker registry

When ready to try, Extrahorizon will provide a token file, which you can use to authenticate against the docker repository by doing as follows in a shell:

cat <token-file> | docker login --username AWS --password-stdin <registry-url>/<image-name>

This is, of course, assuming some kind of unix shell (linux, MacOS, ...). You might need to tweak it a bit for Windows. The idea is that the token file is fed to the docker login process through stdin. If all goes well, you should see Login Succeeded being shown.

Sending the docker image to the register

If the registry is authenticated, you just need to:

docker push <registry-url>/<image-name>:<your-tag>

Remember to replace <your-tag> by whatever tag you chose in the build process

Running the task

Please notify Extrahorizon when a docker image is uploaded. For now we need to manually manage the task to ensure it is using the correct image. Later on, we will integrate this functionality in our API so that this manual step is no longer necessary.

Important

When using a docker-based task, do not use the exh-cli to manage your task (create/update). The result of doing so is uncertain.

https://public.ecr.aws/