Simple boilerplate for building dockerized spring rest server with open api, postgres database and minio/aws s3 storage. Features: 1. automatic creation of user table 2. automatic creation of endpoints and DTOs for login and register 3. Swagger on http://localhost:8070/swagger-ui.html#/ 4. 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 and a minio storage)
cd fast-start
docker-compose up -d
- Add your configuration to application-dev.yml
- For minio setup uncomment initializeAmazon() function from com.project.server.business.StorageService
- 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>${project.basedir}/src/main/resources/open-api/user-management.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 STORAGE_URI=storage_uri \
-e STORAGE_ACCESS_KEY=storage_access \
-e STORAGE_SECRET_KEY=storage_secret \
-e STORAGE_DEFAULT_BUCKET=bucket \
-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)