Add PostgreSQL setup files

This commit is contained in:
raul 2024-12-06 09:03:49 +01:00
parent 7bff94d3b2
commit 65b234f7aa
Signed by: raul
GPG Key ID: C1AA797073F17129
5 changed files with 30 additions and 0 deletions

2
.env.example Normal file
View File

@ -0,0 +1,2 @@
POSTGRES_USER=username
POSTGRES_PASSWORD=password

3
.gitignore vendored
View File

@ -21,3 +21,6 @@
# Go workspace file
go.work
db-config/db-data/**
!db-config/db-data/.blank
.env

0
db-config/db-data/.blank Normal file
View File

12
db-config/init.sql Normal file
View File

@ -0,0 +1,12 @@
-- create a table
CREATE TABLE test(
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
name TEXT NOT NULL,
archived BOOLEAN NOT NULL DEFAULT FALSE
);
-- add test data
INSERT INTO test (name, archived)
VALUES ('test row 1', true),
('test row 2', false);

13
docker-compose.yml Normal file
View File

@ -0,0 +1,13 @@
services:
postgres:
image: 'postgres:latest'
ports:
- 5432:5432
environment:
POSTGRES_DB: drahoot
env_file:
- .env
volumes:
- ./db-config/db-data/:/var/lib/postgresql/data/
- ./db-config/init.sql:/docker-entrypoint-initdb.d/init.sql
user: "1000:1000"