Skip to content

Commit e275d37

Browse files
docs: add beginner step-by-step Getting Started guide (doc 00)
- docs/00-GETTING-STARTED.md: linear walkthrough (requirements -> optional features) with "what success looks like" at each step, for juniors/newcomers - README: link doc 00 as the entry point - Dockerfile: drop unused savedAptMark variable Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6edf82e commit e275d37

3 files changed

Lines changed: 262 additions & 1 deletion

File tree

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ RUN set -eux; \
4040
# build-only tooling afterwards to keep the image lean.
4141
# ---------------------------------------------------------------------------
4242
RUN set -eux; \
43-
savedAptMark="$(apt-mark showmanual)"; \
4443
apt-get update; \
4544
apt-get install -y --no-install-recommends \
4645
build-essential \

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Each document is a self-contained checklist. Tick the boxes as you go.
6464

6565
| # | Document | What it covers |
6666
|---|----------|----------------|
67+
| 0 | [**Getting Started**](docs/00-GETTING-STARTED.md) | 👈 **New here? Start with this** — friendly step-by-step walkthrough |
6768
| 1 | [Requirements](docs/01-REQUIREMENTS.md) | Hardware/software prerequisites, your laptop's budget |
6869
| 2 | [Installation](docs/02-INSTALLATION.md) | Step-by-step from clone to running container |
6970
| 3 | [Configuration](docs/03-CONFIGURATION.md) | Every `.env` & `postgresql.conf` knob explained |

docs/00-GETTING-STARTED.md

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
# 0. Getting Started — a friendly, step-by-step walkthrough
2+
3+
> New to Docker or PostgreSQL? Start here. This guide takes you from a fresh
4+
> machine to a working database with all extensions, then shows the optional
5+
> extras — in plain language, one step at a time. Every step says **what success
6+
> looks like** so you always know you're on track.
7+
8+
If a step misbehaves, jump to [doc 9 — Troubleshooting](09-TROUBLESHOOTING.md).
9+
10+
---
11+
12+
## What is this, in one paragraph?
13+
14+
This repository runs **PostgreSQL 17 inside Docker**, pre-loaded with many useful
15+
**extensions** (Foreign Data Wrappers to query MySQL/SQL Server/other Postgres,
16+
`pgvector` for AI embeddings, `pg_cron` for scheduling, and more). It's tuned so
17+
it stays light on a laptop that's also running other heavy apps. You run a couple
18+
of commands, and you get a ready-to-use database — no manual installs.
19+
20+
**Mental model:**
21+
22+
```
23+
your app (NestJS, etc.) your laptop
24+
─────────────────────── ───────────
25+
│ connects to port 15409
26+
27+
┌───────────────────────────┐ Docker container (capped: 1.5 GB / 2 CPU)
28+
│ PostgreSQL 17 + extensions│ ── data saved in a Docker "volume"
29+
└───────────────────────────┘
30+
│ (optional) Foreign Data Wrappers
31+
32+
other databases (MySQL / SQL Server / Postgres)
33+
```
34+
35+
---
36+
37+
## Step 1 — Check the requirements
38+
39+
You need **Docker** and **Docker Compose v2**. Check:
40+
41+
```bash
42+
docker --version # expect Docker 24+ (this laptop: 29.x)
43+
docker compose version # expect v2+ (this laptop: v5.x)
44+
```
45+
46+
**Success:** both print a version number.
47+
📖 Details & laptop budget: [doc 1 — Requirements](01-REQUIREMENTS.md).
48+
49+
---
50+
51+
## Step 2 — Let Docker run without `sudo` (one-time)
52+
53+
On this laptop the user isn't in the `docker` group yet, so commands would fail
54+
with `permission denied`. Fix it once:
55+
56+
```bash
57+
sudo usermod -aG docker $USER
58+
# then LOG OUT and back in (or run: newgrp docker)
59+
docker run --rm hello-world # verify
60+
```
61+
62+
**Success:** `hello-world` prints "Hello from Docker!" **without** `sudo`.
63+
64+
> Prefer not to? Then prefix every `docker`/`make` command with `sudo`.
65+
66+
---
67+
68+
## Step 3 — Get the code
69+
70+
```bash
71+
git clone https://github.com/programmerShinobi/postgresql-fdw.git
72+
cd postgresql-fdw
73+
```
74+
75+
**Success:** you're inside the `postgresql-fdw` folder (`ls` shows
76+
`docker-compose.yml`, `Makefile`, `docs/`, …).
77+
78+
---
79+
80+
## Step 4 — Configure your secrets (`.env`)
81+
82+
The project never ships real passwords. You create your own local `.env`:
83+
84+
```bash
85+
make init # copies .env.example -> .env AND installs the safety hook
86+
```
87+
88+
Now open `.env` and set a **strong password**. Generate one:
89+
90+
```bash
91+
openssl rand -base64 36 | tr -d '/+=' | cut -c1-48
92+
```
93+
94+
Paste it as `POSTGRES_PASSWORD=...` in `.env`.
95+
96+
**Success:** `.env` exists and `POSTGRES_PASSWORD` is no longer `CHANGE_ME...`.
97+
🔒 `.env` is git-ignored — it will never be committed. See [doc 10 — Security](10-SECURITY.md).
98+
99+
> **Don't change `POSTGRES_DB`** unless you read the note in `.env` (it's linked to
100+
> two settings in `postgresql.conf`). For your first run, leave the defaults.
101+
102+
---
103+
104+
## Step 5 — Build the image
105+
106+
```bash
107+
make build
108+
```
109+
110+
This downloads PostgreSQL 17 and compiles/installs every extension.
111+
112+
**Success:** it ends without errors.
113+
⏳ The **first** build takes a few minutes (it compiles `mysql_fdw`). Later builds
114+
are cached and fast. Grab a coffee. ☕
115+
116+
---
117+
118+
## Step 6 — Start the database
119+
120+
```bash
121+
make up
122+
```
123+
124+
This starts **only** PostgreSQL (optional services stay off — see Step 11).
125+
126+
**Success:**
127+
```bash
128+
make ps # STATUS shows "healthy"
129+
make health # prints "... accepting connections"
130+
```
131+
132+
---
133+
134+
## Step 7 — Confirm the extensions are there
135+
136+
```bash
137+
make extensions
138+
```
139+
140+
**Success:** a table of ~20 extensions: `postgres_fdw`, `mysql_fdw`, `tds_fdw`,
141+
`file_fdw`, `vector`, `pg_cron`, `pg_partman`, `pgaudit`, … plus the basics.
142+
📖 What each one does: [doc 4 — Extensions](04-EXTENSIONS.md).
143+
144+
---
145+
146+
## Step 8 — Connect and try it
147+
148+
Open a database shell:
149+
150+
```bash
151+
make psql
152+
```
153+
154+
Try a query:
155+
156+
```sql
157+
SELECT version();
158+
SELECT gen_random_uuid(); -- from pgcrypto
159+
\dx -- list installed extensions
160+
\q -- quit
161+
```
162+
163+
From your application, use this connection string (with your password):
164+
165+
```
166+
postgresql://local_dev:<password>@127.0.0.1:15409/local_db
167+
```
168+
169+
**Success:** queries return results.
170+
📖 Wiring into NestJS/TypeORM/Prisma: [doc 6 — NestJS Integration](06-NESTJS-INTEGRATION.md).
171+
172+
---
173+
174+
## Step 9 — Day-to-day commands
175+
176+
```bash
177+
make up # start core Postgres
178+
make down # stop everything (your data is kept)
179+
make psql # open a SQL shell
180+
make logs # watch what the database is doing
181+
make stats # live CPU/RAM the container is using
182+
make backup # save a snapshot into ./backups
183+
make help # see all commands
184+
```
185+
186+
> `make down` keeps your data. Only `make destroy` deletes it (it removes the
187+
> volume) — use that to start completely fresh.
188+
189+
**Success:** you can stop/start without losing data.
190+
191+
---
192+
193+
## Step 10 — Make a backup (recommended early)
194+
195+
```bash
196+
make backup
197+
```
198+
199+
**Success:** a file appears in `./backups/` (e.g. `local_db_2026….dump.gz`).
200+
📖 Restoring & scheduled backups: [doc 7 — Backup & Restore](07-BACKUP-RESTORE.md).
201+
202+
---
203+
204+
## Step 11 — Turn on optional features (only if you need them)
205+
206+
A plain `make up` is intentionally minimal. Extras are **opt-in** and capped, so
207+
they never slow your laptop:
208+
209+
```bash
210+
make up-pooler # PgBouncer connection pooler (port 6432) — for many app connections
211+
make up-backup # automatic scheduled backups
212+
make up-ui # Adminer web UI at http://localhost:8080 — a browser GUI
213+
make up-metrics # Prometheus metrics at http://localhost:9187/metrics
214+
make up-all # everything at once
215+
```
216+
217+
Turn them all off again with `make down`, then `make up` for core only.
218+
219+
**Success:** e.g. after `make up-ui`, opening http://localhost:8080 shows a
220+
login page (System: PostgreSQL, Server: `postgres`, your user/DB from `.env`).
221+
📖 Full matrix & tuning: [doc 12 — Optional Features](12-OPTIONAL-FEATURES.md).
222+
223+
---
224+
225+
## Step 12 — (Advanced) Import data from another PostgreSQL
226+
227+
If you have an existing database to copy in:
228+
229+
```bash
230+
cp .env.source.example .env.source # fill in the source connection (gitignored)
231+
./scripts/migration/check-compatibility.sh # checks it'll import cleanly
232+
make up
233+
./scripts/migration/import-from-source.sh
234+
```
235+
236+
**Success:** the compatibility report ends with "Safe to import", and after the
237+
import your tables appear in `make psql` (`\dt`).
238+
📖 Full guide & caveats: [doc 11 — Import from Source](11-IMPORT-FROM-SOURCE.md).
239+
240+
---
241+
242+
## You're done 🎉
243+
244+
You now have a tuned, extension-rich PostgreSQL for development. Recommended next
245+
reads, in order:
246+
247+
1. [Resource Tuning](05-RESOURCE-TUNING.md) — why it's laptop-safe & how to rebalance
248+
2. [Security](10-SECURITY.md) — keep credentials safe (important!)
249+
3. [Optional Features](12-OPTIONAL-FEATURES.md) — pooler, backups, UI, metrics
250+
251+
### Quick "is everything OK?" checklist
252+
253+
- [ ] `make ps` → healthy
254+
- [ ] `make extensions`~20 rows
255+
- [ ] `make psql``SELECT 1;` works
256+
- [ ] `make backup` → a file in `./backups/`
257+
- [ ] You set a strong `POSTGRES_PASSWORD` and never committed `.env`
258+
259+
---
260+
261+
⬅️ Back to the [README](../README.md) · Next: [1. Requirements »](01-REQUIREMENTS.md)

0 commit comments

Comments
 (0)