Skip to main content

Posts

Showing posts from May, 2023

Springboot e-commerce

 Springboot e-commerce git:  https://github.com/HazraSoham/WingsT4Springboot User.java - renamed to EcomUser.java Below is the code snippet how EcomUser.java should be, add constructor and getters and setters also. Have many-to-many with Role Have one-to-one with Cart Have one-to-many with Product @Entity public class EcomUser {           @Id @GeneratedValue (strategy = GenerationType. IDENTITY ) private Integer ecomUserId ; private String username ; private String password ; @ManyToMany (fetch = FetchType. EAGER , cascade = CascadeType. ALL ) @JoinTable (name = "UserRole" , joinColumns = @JoinColumn (name = "ecomUserId" ), inverseJoinColumns = @JoinColumn (name = "roleId" )) private Set<Role> roles ; Role.java - shown below the class, add getter and setters also Have many-to-many with User @Entity public class Role { @Id @GeneratedValue (strategy = GenerationType. IDENTITY ) private Integer roleId ; private String rol

Restaurant API using SpringBoot

 Restaurant API using Spring Boot github repo:  https://github.com/HazraSoham/Kickoff-Springboot-ResturantAPI.git Controller - Add  @RestController  annotation the class      @Autowired private RestaurantService restaurantService ; //to create a restaurant @PostMapping ( "/restaurant/add" ) public ResponseEntity<Object> postRestaurant( @RequestBody Restaurant restaurant ){ return restaurantService .postRestaurant( restaurant ); } //to get a restaurant by id @GetMapping ( "/restaurant/get/{id}" ) public ResponseEntity<Object>getRestaurantById( @PathVariable int id ){ return restaurantService .getRestaurantById( id ); } //to get restaurants which are equal to or greater than the given rating @GetMapping ( "/restaurant/ratings" ) public ResponseEntity<Stream<Restaurant>> getGreaterRating( @RequestParam ( "rating" ) Double rating ){ return r

Build Flask image using docker & docker-compose

 Build Flask Image using docker & docker-compose 1. Create a Dockerfile to build Flask image with Flask application, 'requirements.txt' and expose it in port 5000. 2. Create a 'docker-compose.json' file to create two services named 'python_web_app' and 'db_service' 3. The 'python_web_app' service  should be built from Dockerfile and specify the port as 5000 4. the 'db_service' should be built from image 'redis:alpine' 5. Add a volume to the 'python_web_app' service that mounts the current directory to the working directory inside the container and set the flask envireonment in debug mode. 6. Visit 'http:localhost:5000" to check weather the Flask application is running fine. The container name of 'python_web_app' service should be 'web_container' and container name of 'db_service' should be 'db_container' Here are the instructions for each of the tasks mentioned: Create a file na

Dockerize Gradle application using Jenkins

 Dockerize Gradle application using Jenkins In this challenge we will build and deploy a application using docker and Jenkins A Gradle web project structure is given in the gradle webapp directory which is in the path mentioned below. dev/workspace/sample-project Initialize the gradle webapp directory as a gradle project and configure the build script to - generate a war file - build a docker image named " gradle_image " - run the docker image on a container named " gradle_container ", expose to the port 8001 Create a Dockerfile to deploy the generated war file in tomcat server Initialize git to make gradle webapp directory as your local git repository. Launch jenkins and create a declarative pipeline named gradle-build to run and deploy the gradle application. Ensure that your Gradle application is running on http://localhost:8001/gradle_webapp Let's get started... 1. Initialize the Gradle project: Open the command prompt/ter

Build & Deploy docker image using Gradle

 Build & Deploy docker image using Gradle You are tasked to create a gradle java application, Dockerfile to run the 'springbootify.jar' file on port 8080 , use suitable gradle plugins to configure the gradle application to build a docker image and run the docker container. On successful deployment of docker container, hit the url ( http://localhost:8080/doit ) and you could see the message on the webpage. Note: Jar file 'springbootify.jar' is already given in folder /Desktop/Project no need to build a need jar file. Please do install gradle using the command "sudo apt install gradle" Please do use "sudo service jenkins stop" Create a Docker & gradle application in the path /Desktop/Project Make the gradle project operable for both gradle & gradlew commands Docker base image: openj dk: 12-jdk-alpine. Solving the tasks... sudo apt install gradle sudo service jenkins stop cd /Desktop/Project Crea

Hands-on with Docker and Docker-Compose

  Hands-on with Docker & Docker-Compose (1) Create a "Dockerfile" inside the path "-/Desktop/Project/docker-docker-compose working-with-multiple-services/app", with base image "python:3.7" to dockerize the given Flask application "app.py" (2) Create another "Dockerfile" inside the path "-/Desktop/Project/docker-docker-compose-working-with-multiple-services/db", with base image "postgres" and configure the environment variables postgres user "abc", postgres password "abc@123", postgres db "postgres". (3) Create one more "Dockerfile" inside the path "-/Desktop/Project/docker-docker-compose-working-with-multiple-services/cache", with base image as "redis". (4) Create a "docker-compose.yml" file inside the path "-/Desktop/Project/docker-docker-compose-working-with-multiple-services" with the below specifications,      (4.1) Create three s