diff --git a/angular-frontend/Dockerfile b/angular-frontend/Dockerfile new file mode 100644 index 0000000..d00a0a2 --- /dev/null +++ b/angular-frontend/Dockerfile @@ -0,0 +1,53 @@ +# Build stage +FROM node:14-alpine AS build +WORKDIR /usr/src/app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# Runtime stage +FROM nginx:alpine + +# 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 80 +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;"] diff --git a/angular-frontend/src/app/services/worker.service.ts b/angular-frontend/src/app/services/worker.service.ts index d64cc20..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://localhost: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) { } 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 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 diff --git a/spring-backend/Dockerfile b/spring-backend/Dockerfile new file mode 100644 index 0000000..49f209c --- /dev/null +++ b/spring-backend/Dockerfile @@ -0,0 +1,37 @@ +# 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 + +# 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"] + + +# # 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"] diff --git a/spring-backend/src/main/resources/application.properties b/spring-backend/src/main/resources/application.properties index 10c4f6d..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://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 +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 -spring.jpa.generate-ddl=true \ No newline at end of file