diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d297b14 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +POSTGRES_USER=username +POSTGRES_PASSWORD=password diff --git a/.gitignore b/.gitignore index adf8f72..c18b2fc 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ # Go workspace file go.work +db-config/db-data/** +!db-config/db-data/.blank +.env diff --git a/db-config/db-data/.blank b/db-config/db-data/.blank new file mode 100644 index 0000000..e69de29 diff --git a/db-config/init.sql b/db-config/init.sql new file mode 100644 index 0000000..0ab903e --- /dev/null +++ b/db-config/init.sql @@ -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); + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..35005ca --- /dev/null +++ b/docker-compose.yml @@ -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"