Skip to content

Commit

Permalink
Merge pull request #13 from oseasmoran73/automate-init-script
Browse files Browse the repository at this point in the history
Minor: Create DB dynamically via Docker
  • Loading branch information
januschung authored Sep 8, 2024
2 parents 7cf82da + 454bc6b commit d36b151
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
15 changes: 10 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
version: '3.1'

services:

db:
image: postgres
build:
dockerfile: postgresDB.dockerfile
restart: always
environment:
POSTGRES_PASSWORD: example
POSTGRES_USERNAME: postgres
ports:
- 5432:5432
volumes:
- pgdata:/var/lib/postgresql/data

adminer:
image: adminer
restart: always
ports:
- 8081:8080
- 8081:8080

volumes:
pgdata:
external: false
4 changes: 4 additions & 0 deletions postgresDB.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM postgres
ENV POSTGRES_PASSWORD=example
ENV POSTGRES_USERNAME=postgres
COPY src/main/resources/schema.sql /docker-entrypoint-initdb.d/
6 changes: 3 additions & 3 deletions src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
create table job_application(
create table if not exists job_application(
id serial primary key,
company_name varchar(50),
job_title varchar(50),
Expand All @@ -9,7 +9,7 @@ create table job_application(
status varchar(20)
);

create table profile(
create table if not exists profile(
id serial primary key,
first_name varchar(200),
last_name varchar(200),
Expand All @@ -24,4 +24,4 @@ create table profile(
);

insert into profile(id)
values(1);
values(1);

0 comments on commit d36b151

Please sign in to comment.