Skip to content
Firefly Plus
Docs menu
Docs / Start

Example: Python

A small Flask app served by gunicorn, its Dockerfile, and how to deploy it.

A web app in Flask, served by gunicorn. It answers on the port in PORT, which we set for each instance.

The app

app.py:

from flask import Flask

app = Flask(__name__)


@app.get("/")
def hello():
    return "Hello from Python\n", 200, {"Content-Type": "text/plain; charset=utf-8"}

requirements.txt:

flask==3.1.1
gunicorn==23.0.0

The Dockerfile

FROM python:3.13-slim
WORKDIR /app
ENV PYTHONUNBUFFERED=1
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN useradd --create-home app
USER app
# The platform sets PORT; gunicorn answers on it.
CMD ["sh", "-c", "exec gunicorn --bind 0.0.0.0:${PORT:-8080} --workers 2 app:app"]

It runs as its own user, not as root. PYTHONUNBUFFERED makes your output show in the app’s Logs as it happens.

Deploy it

You can deploy it two ways.

From GitHub

  1. Put these files in a repository on GitHub.
  2. In the dashboard, choose Create app, name it, and choose GitHub repository as its source. Pick the repository and branch.
  3. Keep the web process’s Port at 8080, or any port you like: your app reads it from PORT.
  4. Choose Create app. It builds your Dockerfile and deploys; every push to the branch does it again.

From an image you build

  1. Build the image for 64-bit Linux, and push it to a registry you use, such as Docker Hub or GitHub’s:

    docker build --platform linux/amd64 -t ghcr.io/you/hello-python:1 .
    docker push ghcr.io/you/hello-python:1
  2. Choose Create app, name it, choose Container image, and enter the image in Image.

  3. Keep the web process’s Port at 8080, and choose Create app.

Check it

Once its deploy succeeds, open https://hello-python.fireflyplus.site. It says:

Hello from Python

Something unclear? Email support@firefly.plus.