Incerto13 / example-aws-batch-python

An example AWS Batch Job in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example Python AWS Batch Job

This is an example repo you can fork to create an AWS Batch job. The full process of deploying this repo's Docker Image and the associated AWS Batch infrastrcuture is described in this article.

Installation

First set up a virtual environment to isolate dependencies. You can do this in many ways but as an example:

$ pyenv virtualenv 3.10.0 <chosen-virtualenv-name>
$ pyenv activate <chosen-virtualenv-name>

Then to install dependencies:

$ make install

Running Locally

Run $ make run

Deploying to ECR

You may want to use an Github Action to deploy the image to ECR on pushes to the master branch.

To push new images locally, ensure you have the aws-cli installed then run the following:

$ aws ecr get-login-password --region <aws-region> --profile <named-profile-with-ecr-access> | docker login --username AWS --password-stdin <aws-account-number>.dkr.ecr.<aws-region>.amazonaws.com
$ docker build -t <your-image-name> .
$ docker tag <your-image-name>:latest <aws-account-number>.dkr.ecr.<aws-region>.amazonaws.com/<ecr-repo-name>:latest
$ docker push <aws-account-number>.dkr.ecr.<aws-region>.amazonaws.com/<ecr-repo-name>:latest

Note: the above works only for aws-cli versions >2 and the --profile <named-profile-with-ecr-access commmand line argument is only neccessary if you have multiple AWS profiles.

About

An example AWS Batch Job in Python


Languages

Language:Python 64.4%Language:Dockerfile 21.8%Language:Makefile 13.8%