Simple boilerplate for building dockerized spring rest server with open api and postgres database.
Features:
- automatic creation of user table
- automatic creation of endpoints and DTOs based on open-api schema
- Swagger on http://localhost:8070/swagger-ui.html#/
- integration with logback for elk stack
- Install docker and docker-compose
cd fast-start
chmod u+x docker-compose-ubuntu.sh
./docker-compose-ubuntu.sh
- Build server image in root
mvn clean install dockerfile:build
- Run docker compose (this will start the server with a postgres database)
cd fast-start
docker-compose up -d
- Add your configuration to application-dev.yml
- Start local server with: clean spring-boot:run -Dspring-boot.run.profiles=dev
The project uses openapi v3 generator for models and endpoints For user model and enpoints use the following generator:
<execution>
<id>1</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>https://raw.githubusercontent.com/Jiratech/boilerplate-openapi-schema/master/schema.json</inputSpec>
<generatorName>spring</generatorName>
<modelPackage>openapi.project.model</modelPackage>
<apiPackage>openapi.project.api</apiPackage>
<invokerPackage>openapi.project.invoker</invokerPackage>
<configOptions>
<sourceFolder>target/generated-sources/java/main</sourceFolder>
</configOptions>
</configuration>
</execution>
In adition the boilerpalte provides the automatic generation of DeepVISS (https://deepviss.org/) https://github.com/deepviss-org
- Go to root folder and run:
mvn clean install dockerfile:build
- Run the docker with the following configuration:
docker run --name project -d \
-e "SENTRY_DSN=$SENTRY_DSN" \
-e "SPRING_PROFILES_ACTIVE=prod" \
-e SERVER_PORT=server_port \
-e POSTGRES_URI=postgres_uri \
-e POSTGRES_USERNAME=username \
-e POSTGRES_PASSWORD=password \
-e ACCESS_KEY=jwt_secret \
-e LOG_HOME=/data/logs \
-p desired_port:server_port
project/server
SENTRY_DSN is used for monitoring and error tracking (sentry.io)
