Fargate

Fargate allows you to run you Python applications with virtually no extra requirements. If you can handle HTTP requests, then you can deploy with Fargate.

By default your Docker image will be run as is to handle hTTP requests, bu you can always override the CMD instruction using your application's dashboard.

If you also want to run a background process, you provide the CMD to execute using your applications dashboard. The same docker image will be used, but it will run a different process.

TIP

Check out this Django example implementationopen in new window using SQS messages for background jobs.

Docker image

The following is an example Dockerfile that can be deployed with PythonDeploy and AWS Fargate.

This Dockerfile works for WSGI applications (like Django and Flask).

# Select the base image to use.
FROM python:3.8

# Define your application directory
ARG APP_DIR="/function"

# Set the working directory to your application root directory
WORKDIR ${APP_DIR}

# Install your application dependencies.
COPY requirements.txt .
RUN pip install -r requirements.txt

# Copy your code.
COPY . .

# You can override CMD in the PythonDeploy admin panel.
CMD [ "gunicorn", "your_project.wsgi" ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

TIP

Ensure that gunicorn is a dependency in your project.