Code Monkey home page Code Monkey logo

cool-app's Introduction

cool-app

This is a simple demo app that returns one of several "cool expressions" at random.

This README contains instructions for building the image and testing the app locally.

Build the image

Choose one of the following methods to build an image from the source code:

Dockerfile
Jib
Spring Boot Maven Plugin
Pack

Dockerfile

Review the Dockerfile:

cat Dockerfile

Build the image & publish to the local Docker daemon:

./mvnw package
docker build -t cool-app:1.0.0-dockerfile ./
docker images | grep cool

Optionally, publish to DockerHub (user your org name instead of the example below):

docker login # enter your username and password at the prompts
docker tag cool-app:1.0.0-dockerfile ciberkleid/cool-app:1.0.0-dockerfile
docker push ciberkleid/cool-app:1.0.0-dockerfile

Jib

Review the profiles section of the pom file to see the build configuration using jib-maven-plugin:

cat pom.xml

Build the image & publish to the local Docker daemon:

./mvnw compile jib:dockerBuild -Pjib -Dimage=cool-app:1.0.0-jib
docker images | grep cool

Alternatively, build the image & publish to DockerHub (user your org name instead of the example below):

docker login # enter your username and password at the prompts
./mvnw compile jib:build -Pjib -Dimage=ciberkleid/cool-app:1.0.0-jib

Read more about Jib and configuring the plugin in your pom file here.

Spring Boot Maven Plugin

Review the pom file to validate that Spring Boot version is 2.3.0.M1 or greater and that the default build plugin is spring-boot-maven-plugin:

cat pom.xml

Build the image & publish to the local Docker daemon:

./mvnw spring-boot:build-image
docker images | grep cool

Optionally, publish to DockerHub (user your org name instead of the example below):

docker login # enter your username and password at the prompts
docker tag cool-app:1.0.0-boot ciberkleid/cool-app:1.0.0-boot
docker push ciberkleid/cool-app:1.0.0-boot

Pack

Install the pack CLI.

Build the image & publish to the local Docker daemon:

pack build cool-app:1.0.0-pack --builder cloudfoundry/cnb:bionic
docker images | grep cool

Alternatively, build the image & publish to DockerHub (user your org name instead of the example below):

docker login # enter your username and password at the prompts
pack build ciberkleid/cool-app:1.0.0-pack --builder cloudfoundry/cnb:bionic --publish

Test the app locally

See the image(s) generated by the above approach(es) in your local Docker daemon:

docker images | grep cool

In one terminal window, start the app. Replace TAG_SUFFIX with the appropriate value as shown in the list of images returned by the previous command:

container_id=`docker run -d -p 8080:8080 cool-app:1.0.0-TAG_SUFFIX`

The docker run command returns the id of the running container, which we are storing in a variable. You can also run docker ps to see the running containers.

Send a request to the app. You should see a "cool" quote is returned.

curl http://localhost:8080; echo

Stop the app container using the container_id we captured when starting the app:

docker stop $container_id

cool-app's People

Contributors

ciberkleid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.