This is Yin

Yin Yin Chan

Project Setup: Environment Setup with Docker, Python, and PostgreSQL

by Yin Yin Chan 🤓 June 2026

TL;DR

This is a continuation to the post on Getting Started: Workflow Setup with Github Codespaces, Visual Studio Code, and Docker.

We prepare our dev environment to build an end-to-end data pipeline with a simple python file structure, PostgreSQL and Docker.

Project Setup

Prerequisite skills

Basic Python Terminal & Shell Command Line Docker CLI uv psql

Project files and dockerization

  1. Create your pipeline directory
mkdir pipeline
cd pipeline
touch pipeline.py

You can leave pipeline.py empty for now, or check that it works.

# in pipeline.py
import sys

say_what = sys.argv[1]
print(f"Repeat after me: {say_what}")

In your terminal, check that it works

uv run python pipeline.py "Let's get this party started!"
  1. Initialize a python project and check versions
uv init --python=3.14
uv run which python
uv run python -V
  1. Let’s setup a Dockerfile to create the Docker image
# Start an image with python on it
FROM python:3.14.4-slim

# Use uv in Docker 
# (docs: https://docs.astral.sh/uv/guides/integration/docker/)
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/

# Set working directory within image
WORKDIR /app

# Activate the project virtual environment to install packages 
# (https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment)
ENV PATH="/app/.venv/bin:$PATH"

# Copy dependency files
COPY pyproject.toml .python-version uv.lock ./

# Install dependencies from lock file
RUN uv sync --locked

# Copy application code 
COPY pipeline.py pipeline.py

# Set entry point
ENTRYPOINT ["python", "pipeline.py"]

Environment Variables

  1. We will use a .env in developement
touch .env
  1. Add to .gitignore so we make sure not to commit it from the go.
# in .gitignore
.env
.env.*
!.env.example
  1. Create your own .env using .env.example as a template for all the key values we’ll need for this project

PostgreSQL in Docker

  1. Create the directory for data persistence
mkdir la_meter_parking_postgres_data
  1. Install PostgreSQL CLI as a development dependency
uv add --dev pgcli
  1. Let’s try it out in terminal. In one terminal window, run:
export $(xargs < .env)

docker run -it \
  -e POSTGRES_USER="$POSTGRES_USER" \
  -e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" \
  -e POSTGRES_DB="$POSTGRES_DB" \
  -v $(pwd)/$DATA_PERSISTENCE_DIR:/var/lib/postgresql \
  -p $PORT:$PORT \
  postgres:18

In another terminal window, run:

#use environment variables, or connect with your values in place
export $(xargs < .env)
uv run pgcli -h localhost -p $PORT -u $POSTGRES_USER -d $POSTGRES_DB

Give your own password and then you should be in. Let’s check

\dt

You should see a blank db schema

© 2026 Yin Yin Chan. Designed with heart. Built with code.