Skip to main content

Posts

Showing posts from June, 2023

Building Docker Image with Maven

 Building Docker Image with Maven You are a DevOps Engineer working for ABC Infotech. A client has requested you to build a Docker image using Maven plugin, so that when you package your Maven project. Docker image will be built, and the generated artifacts will be deployed in local git repository  1. Create a Maven java project using CLI with the following configurations - groupId=javaApp  - artifactId maven-docker-image  2. Replace the 'Hello World!' message in the 'App.java' file with 'Hurray! You have successfully built a docker image using Maven' 3. Configure your 'pom.xml' to deploy the generated artifacts in the local git repository to build a docker image 4. The project should be deployed in the local repositary with the following details: - id = maven.repo - name = Maven Artifacts - URL = file:///home/labuser/Desktop/Remote/mavenArtifacts 5. The name of the jar file, repository name af the image should be same as the project artifactId

Create & Dockerize a Flask app with Redis

  Create & Dockerize a Flask app with Redis For this project we would create everything from scratch. Section 1 : We would create the Flask app Section 2 : We would deploy the app as service, along with redis using docker and docker-compose. Section 1 Creating a flask app that returns the count number of times the page was visited. Create a  requirements.txt file, and paste the following dependency name Flask redis Import dependencies using pip install --no-cache-dir -r requirements.txt Create a  app.py file  from flask import Flask from redis import Redis app = Flask(__name__) redis = Redis(host='db_service', port=6379) @app.route('/') def hello():     visit_count = redis.incr('visit_count')     return f"Hello, this page has been visited {visit_count} times." if __name__ == '__main__':     app.run(host='0.0.0.0') We can test the app locally for this we need to: Install virtualenv if it's not already installed: sudo apt-get up