This example demonstrates a single Product Microservice built with FastAPI and PostgreSQL, running in a Podman container. The primary goal of this example is to cover fundamental Podman concepts: building an image and running a container.
-
Podman Desktop:
- Download from: https://podman-desktop.io
-
Python 3.10+:
- Download from: https://www.python.org/downloads/
-
PostgreSQL Database:
- You need a local PostgreSQL server instance.
- Recommended: Install PostgreSQL directly on your machine (e.g., via Homebrew for macOS, apt for Linux, or a standalone installer for Windows). Download from https://www.postgresql.org/download/
- Alternative (using Podman for DB only): If you prefer not to install PostgreSQL directly, you can run a PostgreSQL container temporarily:
Remember to stop/remove it when done:
podman run --name local-postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=products -p 5432:5432 -d postgres:15-alpine
podman stop local-postgres && podman rm local-postgres
-
Database Setup (Ignore thisstep )
The Product Service expects a PostgreSQL database named
productswith userpostgresand passwordpostgres.-
Start your local PostgreSQL server.
-
Create the
productsdatabase: Open your PostgreSQL client (likepsqlin your terminal or a GUI like pgAdmin) and run the following command:CREATE DATABASE products;
(If you used the Podman command to run PostgreSQL locally, this database will be created automatically by the
postgres:15-alpineimage due to thePOSTGRES_DBenvironment variable.)
-
-
Running the Product Service (Using Podman)