https://github.com/grumpy-programmer/spring-mongo-demo
https://github.com/grumpy-programmer/spring-mongo-demo
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/grumpy-programmer/spring-mongo-demo
- Owner: grumpy-programmer
- Created: 2021-08-06T10:16:42.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-12T14:41:26.000Z (over 4 years ago)
- Last Synced: 2025-01-23T21:31:40.731Z (about 1 year ago)
- Language: Java
- Size: 133 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-mongo-demo
## Pre requirements
* java 11
* docker
* docker compose
## Local development
Docker compose contains following services:
* mongo - the mongo database
* mongo-express - the mongo web explorer http://localhost:8081
To setup environment for local development run
```shell
docker-compose up -d
```
this will download all needed images and create containers.
To stop
```shell
docker-compose stop
```
To remove (first stop)
```shell
docker-compose rm
rm -rf volumes
```
## Building gradle project
Use gradle wrapper`./gradlew` script to build the application
```shell
./gradlew build
```
## Building docker image
The [Dockerfile](Dockerfile) to build docker image of the application.
For local development and testing
```shell
docker build -t spring-mongo-demo .
```
For building production docker image
```shell
docker build -t ghcr.io/grumpy-programmer/spring-mongo-demo .
```
This application is using github registry to store
images, [see more](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)
Login to github registry
```shell
# using std input to provide password (GITHUB_TOKEN)
docker login ghcr.io -u USERNAME --password-stdin
# setting password in command line
docker login --username USERNAME --password GITHUB_TOKEN ghcr.io
```
## Github actions
The build pipeline [.github/workflows/build.yml](.github/workflows/main.yml) builds gradle application, create docker
image and push the image to github registry.
Images will have shared tag latest and unique with current version.
Pipeline will for each branch (except main) to build gradle application and docker image. For `main` branch additionally
docker image will be pushed to github registry.
For time optimization [github action cache](https://github.com/actions/cache) is added to pipeline.