Skip to content

Commit b79032a

Browse files
committed
Add basic devcontainer setup
This is still missing testing for other PostgreSQL versions and CRDB. It also doesn't setup testing for different connection types.
1 parent 98e7e9f commit b79032a

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mcr.microsoft.com/devcontainers/go:2-1.25-trixie
2+
3+
RUN apt-get update && apt-get install -y postgresql-common \
4+
&& yes | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh \
5+
&& apt-get install -y postgresql-client-18 \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
USER vscode
9+
RUN go install golang.org/x/tools/cmd/goimports@latest

.devcontainer/devcontainer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "pgx",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}"
6+
}

.devcontainer/docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3.8'
2+
3+
volumes:
4+
postgres-18-data:
5+
6+
services:
7+
app:
8+
build:
9+
context: .
10+
dockerfile: Dockerfile
11+
12+
volumes:
13+
- ../..:/workspaces:cached
14+
15+
environment:
16+
PGUSER: postgres
17+
PGPASSWORD: postgres
18+
PGDATABASE: pgx_test
19+
PGHOST: localhost
20+
21+
# Overrides default command so things don't shut down after the process ends.
22+
command: sleep infinity
23+
24+
postgres-18:
25+
image: postgres:18
26+
restart: unless-stopped
27+
volumes:
28+
- postgres-18-data:/var/lib/postgresql
29+
- ../testsetup/postgresql_setup.sql:/docker-entrypoint-initdb.d/01-setup.sql:ro
30+
network_mode: service:app
31+
environment:
32+
POSTGRES_USER: postgres
33+
POSTGRES_PASSWORD: postgres
34+
POSTGRES_DB: pgx_test
35+
POSTGRES_HOSTNAME: localhost

0 commit comments

Comments
 (0)