Giter Club home page Giter Club logo

build-demo's Introduction

build-demo

This Demo shows different ways of building software in Docker.

Building in Docker

$ docker run -it -v $PWD:/home/gradle/src adoptopenjdk/openjdk11:alpine-slim /bin/sh
# cd /home/gradle/src/
/home/gradle/src # ls
Dockerfile    build.gradle  gradle        gradlew       gradlew.bat   src   gradlew      gradlew.bat
/home/gradle/src # ./gradlew build --no-daemon
…
BUILD SUCCESSFUL in 25s
3 actionable tasks: 3 executed

Building with Docker

$ docker build -t a19/$USER/build-demo .
…
BUILD SUCCESSFUL in 22s
…
Successfully built 00de8f500328
Successfully tagged a19/user/build-demo:latest

You can now see the images:

$ docker images | grep $USER/build-demo
a19/user/build-demo        latest              10292cd1035d        2 minutes ago       512MB

Starting the freshly build container:

$ docker run a19/$USER/build-demo:latest

.   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v2.1.6.RELEASE)

2019-10-13 21:40:14.235  INFO 1 --- [           main] com.innoq.product.Application            : Started Application in 3.489 seconds (JVM running for 4.263)

Using Multi-Staged Builds

$ docker build -f Dockerfile-multi -t a19/$USER/build-demo-multi  .
…
BUILD SUCCESSFUL in 20s
…
Successfully built adad7203c481
Successfully tagged a19/root/build-demo-multi:latest

Compare the size of both images:

$ docker images | grep $USER/build-demo
a19/user/build-demo-multi   latest              adad7203c481        57 seconds ago      158MB
a19/user/build-demo         latest              10292cd1035d        11 minutes ago      512MB

Test if the new Image does work:

$ docker run a19/$USER/build-demo-multi:latest

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.6.RELEASE)

2019-10-13 21:52:50.126  INFO 1 --- [           main] com.innoq.product.Application            : Starting Application on 73468d32d42c with PID 1 (/app/spring-boot-application.jar started by root in /)
2019-10-13 21:52:50.132  INFO 1 --- [           main] com.innoq.product.Application            : No active profile set, falling back to default profiles: default
2019-10-13 21:52:51.820  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9001 (http)

2019-10-13 21:52:52.810  INFO 1 --- [           main] com.innoq.product.Application            : Started Application in 3.381 seconds (JVM running for 4.139)

Using a specific Build Image

$ docker build -f Dockerfile-builder -t a19/build-demo/builder:latest .
…
Successfully built ad62d12483db
Successfully tagged a19/build-demo/builder:latest

Check if the images was build:

$ docker images | grep a19/build-demo/builder
a19/build-demo/builder        latest              e9460a98e29b        11 seconds ago      402MB

Building the Application with the newly created Build-Image:

$ docker build -f Dockerfile-with-builder -t a19/$USER/build-demo-with-builder  .
…
BUILD SUCCESSFUL in 9s
…
Successfully built adad7203c481
Successfully tagged a19/user/build-demo-with-builder:latest

Compare the image sizes:

$ docker images | grep a19/$USER/build-demo-
a19/root/build-demo-with-builder   latest              adad7203c481        18 minutes ago      158MB
a19/root/build-demo-multi          latest              adad7203c481        18 minutes ago      158MB

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.