DevOps Classroom notes 06/Oct/2024

Containerize Applications

  • Making applications run in the container is referred as containerizations i.e. Building images with our app in it
  • For doing this we have two approaches
    • Manual Process
    • Dockerfile Approach

Activity 1: Create a website

  • Template: Refer Here
  • Websites require webservers, We can use any webserver (nginx/apache)
    • We need nginx
  • Manual steps to create website on a server (ubuntu)
sudo apt update
sudo apt install nginx -y
sudo apt install unzip -y
cd /tmp
wget https://www.free-css.com/assets/files/free-css-templates/download/page296/finexo.zip
unzip finexo.zip
  • All the websites have a folder from which websites are served
sudo mv /tmp/finexo-html /var/www/html/crypto

  • Manual approach in docker
    • Lets pull the nginx image nginx:1.27 and view details
    • Now run the container in the detached mode with port exposed
      docker container run -d -P --name crypto-manual nginx:1.27
    • Download the zip file locally cd /tmp && wget https://www.free-css.com/assets/files/free-css-templates/download/page296/finexo.zip
    • Now copy the folder into nginx container

    • Now the container crypto-manual has application running inside, we need to create a image of this container
    • Now lets create a new container from the image
      docker container run -d --name crypto1 -P myweb:m1.0

  • Dockerfile Approach
    • Create a file called as Dockerfile in a folder with following content
      Dockerfile
      FROM nginx:1.27
      LABEL author='khaja'
      EXPOSE 80
      COPY finexo-html/ /usr/share/nginx/html/crypto
    • Now build the image using command docker image build -t myweb:a1.0 .

    • Now create some containers and cross check

  • Dockerfile approach is widely used to create container images as it is repeatable and automatable.

Activity 2: Run a Spring boot application inside container (Containerizing Spring boot application.)

  • Refer Here for springpetclinic jar file
  • To run this application we need java 17 jdk
cd /tmp
wget https://khajareferenceapps.s3.ap-south-1.amazonaws.com/spring-petclinic-3.2.0-SNAPSHOT.jar
java -jar /tmp/spring-petclinic-3.2.0-SNAPSHOT.jar

  • What is required to run this application
    • java 17
  • Java comes with two different installations
    • JDK: This is required to build and run the java applications
    • JRE: This is required to run the java applications

Activity 3: Run a reactjs application

  • Sample application Refer Here
  • Install nodejs and npm
  • manual steps
git clone https://github.com/aditya-sridhar/simple-reactjs-app.git
cd simple-reactjs-app
npm install
npm run start

Approach

  1. Figure out the manual steps on how to deploy your applicaton onto server (os level)
  2. Ensure the dependencies (softwares required to run application)
  3. Now Create a Dockerfile with instructions to containerize your application.
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%