This is a proverb app. currently it contains 11 positive proverbs. we can get a random solo proverb using (GET /) and can get all of them using (GET /proverbs) as Json.
Here I have used sbt-native-packager for docker packaging, I'm using playframework so it's already configured.
sbt
> compile
> Docker / stage
> Docker / publishLocal
This will create a local docker image with name packageName+version
>APPLICATION_SECRET
>HTTP_PORT
dockerEnvVars ++= Map( ("APPLICATION_SECRET", "mysecretKey1234567890-!@#$%^&*()_"), ("HTTP_PORT", "9500") )
Notes:
here we're declared APPLICATION_SECRET as an env and you can see it in the build.sbt but it's not a good Idea when creating a production version from this docker image. when creating production version of docker image from this, delete the APPLICATION_SECRET from dockerEnvVars in build.sbt. and when running the image we have to declare that environment variable. ex:
docker run -it -p80:9500 -e APPLICATION_SECRET=sdfasdfHEGSHDKSDKSDHKHSKDKSDSKJDSJDHHSDSAHAHAH --name=proverbContainer proverb-app:1.0.1
dockerBaseImage := "openjdk:11-jre"
Docker / packageName := "proverb-app"
docker run --rm -p 9500:9500 --name myProverbApp proverb-app:1.0.1
here,
- --rm will remove the container when exit.
- ImageName -> proverb-app:1.0.1
- ContainerName -> myProverbApp
Here I'm using Jenkins for automating the CICD Continuous Integration(CI) Steps:
> Build
> Test
> Package
> Storing Package (ex: docker hub/nexus,github)
Continuous Deployment(CD):
> Get package From Storage (ex: docker hub/nexus,github)
> Publish to Production Environment