Slim Starter Pack: Python 'Hello World'

Hello Python developers!

Optimize and harden your containerized applications the easy way — with Slim.AI.

This Starter Kit will help you proactively remove vulnerabilities from your applications.

Simply replace the application code here with your own application, run it through Slim.AI's automated container optimization process, and you'll remove up to 90-percent of the image's vulnerabilities while also making it up to 30X smaller.

No more chasing down hard to patch vulnerabilities that your application isn't even using, and you can use any base image you want — even python:latest.

Optimization Results

Get Started

To start a Python application application, you'll need the following libraries installed locally, or running in a dev environment link GitPod, Docker Environments, or Code Spaces.

# requirements.txt
Flask=2.2.1

Sample Application

Our sample application is a simple REST API that merely returns "Hello World!".

While this app is simple, it's a great starting point for more complex development.

Project structure

Dockerfile
|- app
|-- app.py
|-- requirements.txt
|- tests
|-- test.py

Code sample

@app.route("/")
def hello():
    return jsonify({"msg": "Hello, World!"})

Replace this placeholder code with your own application code, and install any necessary dependencies, to create your own "slimmable" container.

Sample Dockerfile

Our Dockerfile builds off of the python:latest image and starts at 951 MB.

FROM python:latest

COPY ./app /app

RUN pip install -r /app/requirements.txt

EXPOSE 5000

ENTRYPOINT ["python","/app/app.py"]

The slimming process reduces the size by 15X to just 61 MB.