-
Download and install docker
-
Run the following
Note
|
For a more convenient way to run the app, refer to docker/README.adoc. |
# Pull postgres docker image, one time. docker pull postgres:11 docker images # To verify pulled image, one time. docker image inspect postgres:11 # Run Postgres docker run --name dev-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:11 docker container list CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c1bc4a9ed08f postgres:11 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:5432->5432/tcp dev-postgres # CREATE db coursedb docker exec dev-postgres psql -U postgres -c "CREATE DATABASE coursedb" CREATE DATABASE # Open another terminal cd ~/dev/github git clone https://github.com/weipingc/SpringBootAPI.git cd SpringBootAPI ./mvnw clean bash startApi.sh
Setup API doc and Swagger: https://www.baeldung.com/spring-rest-openapi-documentation
API doc(JSON): http://localhost:8080/v3/api-docs/
API doc(YAML): http://localhost:8080/v3/api-docs.yaml
Swagger UI: http://localhost:8080/swagger-ui.html
Karate test: https://semaphoreci.com/community/tutorials/testing-a-java-spring-boot-rest-api-with-karate
Karate demo, example feature files: https://intuit.github.io/karate/karate-demo/
Secure web app: https://spring.io/guides/gs/securing-web/
Configure headers: https://intuit.github.io/karate/#http-header-manipulation
# in brower # go to http://localhost:8080/employees # or curl -v http://localhost:8080/employees # Shutdown app Ctrl-C docker stop dev-postgres # Restart docker start dev-postgres # Verify docker container dev-postgres is running, stop, restart docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f2d2922b5af6 postgres:11 "docker-entrypoint.s…" 16 minutes ago Up 16 minutes 0.0.0.0:5432->5432/tcp dev-postgres docker stop dev-postgres dev-postgres docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f2d2922b5af6 postgres:11 "docker-entrypoint.s…" 16 minutes ago Exited (137) 4 seconds ago dev-postgres docker start dev-postgres dev-postgres # Remove all stop container docker container prune