diff --git a/JavaScript/db/docker/Makefile b/JavaScript/db/docker/Makefile new file mode 100644 index 0000000..9ed575a --- /dev/null +++ b/JavaScript/db/docker/Makefile @@ -0,0 +1,16 @@ +start: ## start the database +start: + @docker-compose up -d db + +stop: ## stop the database +stop: + @docker-compose stop db + +logs: ## show logs +logs: + @docker-compose logs -f db + +psql: ## run psql +psql: start +psql: + @docker-compose exec db sh -c 'psql -U $$POSTGRES_USER $$POSTGRES_DB' diff --git a/JavaScript/db/docker/README.md b/JavaScript/db/docker/README.md new file mode 100644 index 0000000..548edd7 --- /dev/null +++ b/JavaScript/db/docker/README.md @@ -0,0 +1,33 @@ +## Working with database + +The script runs PostgresSQL 14 in Docker. + +To run database locally use the following commands: + +* it runs the database server: +```bash +make start +# or +docker-compose up -d db +``` + +* it stops the database server: +```bash +make stop +#or +docker-compose stop db +``` + +* it shows logs from the database server: +```bash +make logs +#or +docker-compose logs -f db +``` + +* it runs psql: +```bash +make psql +#or +docker-compose exec db sh -c 'psql -U $$POSTGRES_USER $$POSTGRES_DB' +``` \ No newline at end of file diff --git a/JavaScript/db/docker/docker-compose.yml b/JavaScript/db/docker/docker-compose.yml new file mode 100644 index 0000000..e14d7f8 --- /dev/null +++ b/JavaScript/db/docker/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.8' + +services: + db: + image: postgres:14-alpine + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - 5432:5432 + volumes: + - ../setup.sh:/docker-entrypoint-initdb.d/setup.sh:ro + - ../install.sql:/install.sql:ro + - ../structure.sql:/structure.sql:ro + - ../data.sql:/data.sql:ro \ No newline at end of file