DevOps Classroom Series – 02/Sept/2021

Docker image building

  • Manual Steps:
    • Ensure python is installed
    • Ensure pip is installed
    • clone the code from github git clone https://github.com/khajasampleapps/basicflask.git
    • Execute pip install -r requirements.txt
    • To run your application python app.py
  • Refer Here for the Dockerfile
  • Now if we want to make this image available to others, we need to push the image to the registry.
  • Generally the format for registry is <username>/<image>:<tag>
  • DockerHub:
    • This is a public registry and also it has private registry option
    • Execute the command docker login
    • Now push the tagged image
    • Now any one can run this flask application
    docker container run -d -P shaikkhajaibrahim/flaskdemo:1.0.0
    
  • Other Registries
    • AWS ECR: This supports public and private registries hosted on AWS.
    • Azure Container Registry: This is registry hosted on azure Refer Here
    • Artifactory/jfrog: Refer Here

Multi Staged Builds

  • Overview:
  • Lets try to build the springpetclinic
  • Manual steps:
    • this needs jdk 11
    • We need maven
    git clone https://github.com/spring-projects/spring-petclinic.git
    cd spring-petclinic
    mvn package
    # this generates the jar file
    
  • Dockerfile with multistaged build
FROM maven:3-openjdk-11 AS builder
RUN git clone https://github.com/spring-projects/spring-petclinic.git \
    && cd spring-petclinic \
    && mvn package


FROM openjdk:11
LABEL author="khaja"
EXPOSE 8080
COPY --from=builder /spring-petclinic/target/spring-petclinic-2.5.0-SNAPSHOT.jar /spring-petclinic.jar
CMD ["java", "-jar", "/spring-petclinic.jar"]
  • Lets try to build the gameoflife
  • Manual steps:
    • This requires jdk 8
    git clone https://github.com/wakaleo/game-of-life.git
    cd game-of-life
    mvn package
    
  • Exercise: Create a mutlistage build for gameoflife and springpetclinic and push the image to docker hub and any private registry.

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio
Exit mobile version
%%footer%%