Skip to content
Snippets Groups Projects
Commit 2c9057ec authored by Lars Johansson's avatar Lars Johansson
Browse files

Update documentation and add docker compose file with database demo content

Update documentation.
Update location of database scripts.
Add docker compose file with database demo content.
parent 471fe64b
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ Tools
* Java 17 (openjdk)
* Maven 3.8+ (e.g. 3.8.5)
* PostgreSQL (9.6 client lib)
* Docker (docker engine 18.06.0+, docker compose, compose file version 3.7)
* Docker (compose file version 3.7 to be supported, docker engine 20+ recommended)
* Git
Dependencies
......@@ -28,6 +28,8 @@ Dependencies
* springframework
* testcontainers
In addition, Hibernate is used through Springframework.
### Set up development environment and test
#### Checkout and build
......@@ -36,22 +38,30 @@ Dependencies
* `cd directory`
* `mvn clean install`
#### Start application (with database)
#### Start application
For first time users, recommended way to start application is with Docker and database with demo content.
Either
Either with Docker
* start the application and database
* `docker-compose up --build`
* start the application with database
* existing container
* `docker-compose up --build`
* empty
* `docker-compose -f docker-compose-integrationtest.yml up --build`
* demo content
* `docker-compose -f docker-compose-demo.yml up --build`
* start the application without database
* make sure database available as in `src/main/resources/application.properties`
* have local docker compose file without postgres container
* browse to `http://localhost:8080/swagger-ui.html`
or
or with `java -jar`
* make sure database available as in `src/main/resources/application.properties`
* start the application
* `java -jar target/naming-backend-*.jar`
Then
* browse to `http://localhost:8080/swagger-ui.html`
* browse to `http://localhost:8083/swagger-ui.html`
#### Integration tests with Docker containers
......@@ -72,6 +82,11 @@ Thereafter a number of http requests (GET) and curl commands (POST, PUT, PATCH,
#### Note
* *Do not*
* *commit sensitive data*
* *modify docker-compose files unless necessary*
* `application.properties` available in both ´src/main/resources´ and `src/test/resources`. Key difference is that in-memory database is used in test.
* Flyway not (yet) used
* Pre-populated database to be available if data to be available at start of application. Otherwise database may be populated through `curl` at command line or Swagger UI.
* See `src/test/resources` and sub folders for database scripts. This includes scripts for database schema, migration and example content.
* If no prior database is available, see integration tests for examples on how to populate database. E.g. tests may be debugged and database content may be examined at any debug point. It's possible to backup database at such debug point and later restore it outside test. In such way, database may be set to state of choice.
......@@ -81,7 +96,6 @@ Thereafter a number of http requests (GET) and curl commands (POST, PUT, PATCH,
volumes:
- ./src/test/resources/db/data/dump-discs_names_namesit.sql:/docker-entrypoint-initdb.d/dump-discs_names_namesit.sql
```
* `application.properties` available in both ´src/main/resources´ and `src/test/resources`. Key difference is that in-memory database is used in test.
#### Recommentation
......
# ------------------------------------------------------------------------------
# Copyright (C) 2022 European Spallation Source ERIC.
# ------------------------------------------------------------------------------
version: '3.7'
services:
naming:
container_name: "naming"
build: ./
networks:
- naming-net
ports:
- "8080:8083"
depends_on:
postgres:
condition: service_healthy
command: "java -jar /naming/naming-backend.jar"
postgres:
container_name: "postgres"
image: "postgres:9.6.7"
networks:
- naming-net
ports:
- "5432:5432"
environment:
POSTGRES_DB: discs_names
POSTGRES_USER: discs_names
POSTGRES_PASSWORD: discs_names
PGDATA: /var/lib/postgresql/data/pgdata
healthcheck:
test: ["CMD-SHELL", "pg_isready -U discs_names"]
interval: 10s
timeout: 5s
retries: 10
volumes:
- ./src/test/resources/db/data/dump-discs_names_namesit.sql:/docker-entrypoint-initdb.d/dump-discs_names_namesit.sql
volumes:
naming-data:
networks:
naming-net:
driver: bridge
......@@ -32,10 +32,10 @@ services:
timeout: 5s
retries: 10
volumes:
- ./src/test/resources/db/schema_migration/V1__Initial.sql:/docker-entrypoint-initdb.d/V1__Initial.sql
- ./src/test/resources/db/schema_migration/V2__Commit_Msg_to_Device.sql:/docker-entrypoint-initdb.d/V2__Commit_Msg_to_Device.sql
- ./src/test/resources/db/schema_migration/V3__Notification_CC_List.sql:/docker-entrypoint-initdb.d/V3__Notification_CC_List.sql
- ./src/test/resources/db/schema_migration/V4__Schema_data_migration.sql:/docker-entrypoint-initdb.d/V4__Schema_data_migration.sql
- ./src/main/resources/db/migration/V1__Initial.sql:/docker-entrypoint-initdb.d/V1__Initial.sql
- ./src/main/resources/db/migration/V2__Commit_Msg_to_Device.sql:/docker-entrypoint-initdb.d/V2__Commit_Msg_to_Device.sql
- ./src/main/resources/db/migration/V3__Notification_CC_List.sql:/docker-entrypoint-initdb.d/V3__Notification_CC_List.sql
- ./src/main/resources/db/migration/V4__Schema_data_migration.sql:/docker-entrypoint-initdb.d/V4__Schema_data_migration.sql
volumes:
naming-data:
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment