Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions angular-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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;"]
4 changes: 3 additions & 1 deletion angular-frontend/src/app/services/worker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }

Expand Down
2 changes: 1 addition & 1 deletion angular-frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>AngularFrontend</title>
<title>myAngularFrontend</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions spring-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 11 additions & 4 deletions spring-backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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