Search…
Example

Define an API

1
# main.py
2
3
print("hello world")
Copied!

Create a Dockerfile

1
FROM python:3.8-slim
2
3
COPY main.py /
4
5
CMD exec python main.py
Copied!

Build an image

1
docker build . -t hello-world
Copied!

Run a container locally

1
docker run -it --rm hello-world
Copied!

Login to ECR

1
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com
Copied!

Create a repository

1
aws ecr create-repository --repository-name hello-world
Copied!

Tag the image

1
docker tag hello-world <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/hello-world
Copied!

Push the image

1
docker push <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/hello-world
Copied!

Configure a Cortex deployment

1
# cortex.yaml
2
3
- name: hello-world
4
kind: TaskAPI
5
pod:
6
containers:
7
- name: api
8
image: <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/hello-world
9
command: ["python", "main.py"]
Copied!

Create a Cortex deployment

1
cortex deploy
Copied!

Get the API endpoint

1
cortex get hello-world
Copied!

Make a request

1
curl -X POST -H "Content-Type: application/json" -d '{}' http://***.amazonaws.com/hello-world
Copied!

View the logs

1
cortex logs hello-world <JOB_ID>
Copied!
Last modified 3mo ago