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
Project files and dockerization
- 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!"
- Initialize a python project and check versions
uv init --python=3.14
uv run which python
uv run python -V
- Let’s setup a
Dockerfileto 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
- We will use a
.envin developement
touch .env
- Add to
.gitignoreso we make sure not to commit it from the go.
# in .gitignore
.env
.env.*
!.env.example
- Create your own
.envusing.env.exampleas a template for all the key values we’ll need for this project
PostgreSQL in Docker
- Create the directory for data persistence
mkdir la_meter_parking_postgres_data
- Install PostgreSQL CLI as a development dependency
uv add --dev pgcli
- 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
