From e2384ada9e9689b7ce776c7f02058ebe308fb09a Mon Sep 17 00:00:00 2001 From: Gaurav Karemore <95206483+gauravrajlaxmi@users.noreply.github.com> Date: Thu, 23 Jan 2025 23:40:21 +0530 Subject: [PATCH 1/9] Update worker.service.ts --- angular-frontend/src/app/services/worker.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-frontend/src/app/services/worker.service.ts b/angular-frontend/src/app/services/worker.service.ts index d64cc20..667cc65 100644 --- a/angular-frontend/src/app/services/worker.service.ts +++ b/angular-frontend/src/app/services/worker.service.ts @@ -9,7 +9,7 @@ import { Worker } from '../models/worker'; }) export class WorkerService { - private getUrl: string = "http://localhost:8080/api/v1/workers"; + private getUrl: string = "http://54.83.90.121:8080/api/v1/workers"; constructor(private _httpClient: HttpClient) { } From 598cc93e83b765b26761e9778517de62e641376b Mon Sep 17 00:00:00 2001 From: Gaurav Karemore <95206483+gauravrajlaxmi@users.noreply.github.com> Date: Thu, 23 Jan 2025 23:41:41 +0530 Subject: [PATCH 2/9] Update application.properties --- spring-backend/src/main/resources/application.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-backend/src/main/resources/application.properties b/spring-backend/src/main/resources/application.properties index 10c4f6d..d44714f 100644 --- a/spring-backend/src/main/resources/application.properties +++ b/spring-backend/src/main/resources/application.properties @@ -1,5 +1,5 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/springbackend?useSSL=false -spring.datasource.username=springbackend -spring.datasource.password=springbackend +spring.datasource.url=jdbc:mysql://springbackend1.c9ssayqq8va2.us-east-1.rds.amazonaws.com:3306/springbackend?useSSL=false +spring.datasource.username=admin +spring.datasource.password=admin123 -spring.jpa.generate-ddl=true \ No newline at end of file +spring.jpa.generate-ddl=true From bcb07b04750dbdd9c7ec6e511213985668c8c67c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 23 Jan 2025 18:26:27 +0000 Subject: [PATCH 3/9] fsf --- angular-frontend/Dockerfile | 29 +++++++++++++++++++++++++++++ spring-backend/Dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 angular-frontend/Dockerfile create mode 100644 spring-backend/Dockerfile diff --git a/angular-frontend/Dockerfile b/angular-frontend/Dockerfile new file mode 100644 index 0000000..8d9b993 --- /dev/null +++ b/angular-frontend/Dockerfile @@ -0,0 +1,29 @@ +# Use official Node.js image as the base image +FROM node:14-alpine AS build + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Copy package.json and package-lock.json (if available) +COPY package*.json ./ + +# Install project dependencies +RUN npm install + +# Copy the rest of the application code +COPY . . + +# Build the Angular application +RUN npm run build + +# Use NGINX as the production server +FROM nginx:alpine + +# Copy the built artifact from the previous stage to NGINX web server directory +COPY --from=build /usr/src/app/dist/angular-frontend /usr/share/nginx/html + +# Expose port 80 to the outside world +EXPOSE 80 + +# Start NGINX server when the container starts +CMD ["nginx", "-g", "daemon off;"] diff --git a/spring-backend/Dockerfile b/spring-backend/Dockerfile new file mode 100644 index 0000000..06c23e5 --- /dev/null +++ b/spring-backend/Dockerfile @@ -0,0 +1,22 @@ +# Use Ubuntu as base image +FROM ubuntu:latest + +# Install dependencies +RUN apt-get update && \ + apt-get install -y openjdk-8-jdk maven && \ + rm -rf /var/lib/apt/lists/* + +# Set the working directory in the container +WORKDIR /app + +# Copy the Maven project directory into the container +COPY . /app + +# Build the Maven project +RUN mvn clean package -Dmaven.test.skip=true + +# Expose the port the application runs on +EXPOSE 8080 + +# Command to run the application +CMD ["java", "-jar", "target/spring-backend-v1.jar"] From eb28159853608f4c13e39acafcb3caf5330bc8a1 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 23 Jan 2025 18:31:56 +0000 Subject: [PATCH 4/9] index --- angular-frontend/src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-frontend/src/index.html b/angular-frontend/src/index.html index cde9439..166f7ba 100644 --- a/angular-frontend/src/index.html +++ b/angular-frontend/src/index.html @@ -2,7 +2,7 @@ - AngularFrontend + myAngularFrontend From 4bee03180a5c07168a35cba9fd025b86801284b5 Mon Sep 17 00:00:00 2001 From: Gaurav Karemore <95206483+gauravrajlaxmi@users.noreply.github.com> Date: Tue, 23 Dec 2025 09:34:55 +0530 Subject: [PATCH 5/9] Refactor datasource configuration to use env variables Updated database connection properties to use environment variables. --- .../src/main/resources/application.properties | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spring-backend/src/main/resources/application.properties b/spring-backend/src/main/resources/application.properties index d44714f..91a4559 100644 --- a/spring-backend/src/main/resources/application.properties +++ b/spring-backend/src/main/resources/application.properties @@ -1,5 +1,12 @@ -spring.datasource.url=jdbc:mysql://springbackend1.c9ssayqq8va2.us-east-1.rds.amazonaws.com:3306/springbackend?useSSL=false -spring.datasource.username=admin -spring.datasource.password=admin123 +# spring.datasource.url=jdbc:mysql://springbackend1.c9ssayqq8va2.us-east-1.rds.amazonaws.com:3306/springbackend?useSSL=false +#spring.datasource.username=admin +#spring.datasource.password=admin123 + +#spring.jpa.generate-ddl=true +spring.datasource.url=${SPRING_DATASOURCE_URL} +spring.datasource.username=${SPRING_DATASOURCE_USERNAME} +spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} spring.jpa.generate-ddl=true +spring.jpa.hibernate.ddl-auto=update + From 9eba1b9ad0167fd41b090c4cdb905c94b1c26c39 Mon Sep 17 00:00:00 2001 From: Gaurav Karemore <95206483+gauravrajlaxmi@users.noreply.github.com> Date: Tue, 23 Dec 2025 09:39:38 +0530 Subject: [PATCH 6/9] Change getUrl to relative API endpoint Updated the getUrl to use a relative path instead of an absolute URL. --- angular-frontend/src/app/services/worker.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/angular-frontend/src/app/services/worker.service.ts b/angular-frontend/src/app/services/worker.service.ts index 667cc65..de5346d 100644 --- a/angular-frontend/src/app/services/worker.service.ts +++ b/angular-frontend/src/app/services/worker.service.ts @@ -9,7 +9,9 @@ import { Worker } from '../models/worker'; }) export class WorkerService { - private getUrl: string = "http://54.83.90.121:8080/api/v1/workers"; + // private getUrl: string = "http://54.83.90.121:8080/api/v1/workers"; + private getUrl = "/api/v1/workers"; + constructor(private _httpClient: HttpClient) { } From 40c79acce27dc1b7f9709bddb842046047cf14c5 Mon Sep 17 00:00:00 2001 From: Gaurav Karemore <95206483+gauravrajlaxmi@users.noreply.github.com> Date: Tue, 23 Dec 2025 19:54:55 +0530 Subject: [PATCH 7/9] Refactor Dockerfile for multi-stage build --- angular-frontend/Dockerfile | 58 ++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/angular-frontend/Dockerfile b/angular-frontend/Dockerfile index 8d9b993..d00a0a2 100644 --- a/angular-frontend/Dockerfile +++ b/angular-frontend/Dockerfile @@ -1,29 +1,53 @@ -# Use official Node.js image as the base image +# Build stage FROM node:14-alpine AS build - -# Set the working directory in the container WORKDIR /usr/src/app - -# Copy package.json and package-lock.json (if available) COPY package*.json ./ - -# Install project dependencies RUN npm install - -# Copy the rest of the application code COPY . . +RUN npm run build -# Build the Angular application -RUN npm run build - -# Use NGINX as the production server +# Runtime stage FROM nginx:alpine -# Copy the built artifact from the previous stage to NGINX web server directory +# Remove default NGINX config +RUN rm /etc/nginx/conf.d/default.conf + +# Copy your custom config +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Copy Angular build output COPY --from=build /usr/src/app/dist/angular-frontend /usr/share/nginx/html -# Expose port 80 to the outside world EXPOSE 80 - -# Start NGINX server when the container starts CMD ["nginx", "-g", "daemon off;"] + + +# # Use official Node.js image as the base image +# FROM node:14-alpine AS build + +# # Set the working directory in the container +# WORKDIR /usr/src/app + +# # Copy package.json and package-lock.json (if available) +# COPY package*.json ./ + +# # Install project dependencies +# RUN npm install + +# # Copy the rest of the application code +# COPY . . + +# # Build the Angular application +# RUN npm run build + +# # Use NGINX as the production server +# FROM nginx:alpine + +# # Copy the built artifact from the previous stage to NGINX web server directory +# COPY --from=build /usr/src/app/dist/angular-frontend /usr/share/nginx/html + +# # Expose port 80 to the outside world +# EXPOSE 80 + +# # Start NGINX server when the container starts +# CMD ["nginx", "-g", "daemon off;"] From 30d5e10c8f0b725fde96fe20a8013c85008badf4 Mon Sep 17 00:00:00 2001 From: Gaurav Karemore <95206483+gauravrajlaxmi@users.noreply.github.com> Date: Tue, 23 Dec 2025 19:55:56 +0530 Subject: [PATCH 8/9] Refactor Dockerfile for multi-stage build --- spring-backend/Dockerfile | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/spring-backend/Dockerfile b/spring-backend/Dockerfile index 06c23e5..49f209c 100644 --- a/spring-backend/Dockerfile +++ b/spring-backend/Dockerfile @@ -1,22 +1,37 @@ -# Use Ubuntu as base image -FROM ubuntu:latest - -# Install dependencies -RUN apt-get update && \ - apt-get install -y openjdk-8-jdk maven && \ - rm -rf /var/lib/apt/lists/* +# Build stage +FROM maven:3.9.6-eclipse-temurin-8 AS build +WORKDIR /app +COPY pom.xml . +COPY src ./src +RUN mvn clean package -DskipTests -# Set the working directory in the container +# Runtime stage +FROM eclipse-temurin:8-jre WORKDIR /app +COPY --from=build /app/target/spring-backend-v1.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "app.jar"] -# Copy the Maven project directory into the container -COPY . /app -# Build the Maven project -RUN mvn clean package -Dmaven.test.skip=true +# # Use Ubuntu as base image +# FROM ubuntu:latest -# Expose the port the application runs on -EXPOSE 8080 +# # Install dependencies +# RUN apt-get update && \ +# apt-get install -y openjdk-8-jdk maven && \ +# rm -rf /var/lib/apt/lists/* + +# # Set the working directory in the container +# WORKDIR /app + +# # Copy the Maven project directory into the container +# COPY . /app + +# # Build the Maven project +# RUN mvn clean package -Dmaven.test.skip=true + +# # Expose the port the application runs on +# EXPOSE 8080 -# Command to run the application -CMD ["java", "-jar", "target/spring-backend-v1.jar"] +# # Command to run the application +# CMD ["java", "-jar", "target/spring-backend-v1.jar"] From 2bcab100b3ea8d596b132c4da4e60eb0203e01c8 Mon Sep 17 00:00:00 2001 From: Gaurav Karemore <95206483+gauravrajlaxmi@users.noreply.github.com> Date: Tue, 23 Dec 2025 19:58:07 +0530 Subject: [PATCH 9/9] Add docker-compose configuration for backend and frontend --- docker-compose.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..552870c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.9" + +services: + backend: + image: ${BACKEND_IMAGE} + container_name: spring_backend + ports: + - "8080:8080" + environment: + SPRING_DATASOURCE_URL: jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?${DB_PARAMS} + SPRING_DATASOURCE_USERNAME: ${DB_USER} + SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD} + restart: always + + frontend: + image: ${FRONTEND_IMAGE} + container_name: angular_frontend + ports: + - "80:80" + depends_on: + - backend + restart: always