diff --git a/SpringDataPlatform/README.md b/SpringDataPlatform/README.md index 783b1be31..814cbc747 100644 --- a/SpringDataPlatform/README.md +++ b/SpringDataPlatform/README.md @@ -54,6 +54,12 @@ ARCHITECTURE : ```bash docker-compose up +# rebuild (use updated java code) and run +docker-compose up --build + +# restart +docker-compose restart + #-------------------------- # Macbook m1 #-------------------------- diff --git a/SpringDataPlatform/backend/DataPlatform/FlinkRestService/src/main/resources/application.properties b/SpringDataPlatform/backend/DataPlatform/FlinkRestService/src/main/resources/application.properties index de4a0f685..de70959e6 100644 --- a/SpringDataPlatform/backend/DataPlatform/FlinkRestService/src/main/resources/application.properties +++ b/SpringDataPlatform/backend/DataPlatform/FlinkRestService/src/main/resources/application.properties @@ -1,5 +1,5 @@ # spring -server.port=9999 +server.port=${SERVER_PORT:9999} # upload file server.tomcat.max-http-form-post-size=20MB diff --git a/SpringDataPlatform/docker-compose.yml b/SpringDataPlatform/docker-compose.yml index 770f55140..2a721f6b1 100644 --- a/SpringDataPlatform/docker-compose.yml +++ b/SpringDataPlatform/docker-compose.yml @@ -1,11 +1,12 @@ version: '3' services: - app: + app1: restart: always - build: ./backend/DataPlatform + build: ./backend/DataPlatform/FlinkRestService # backend dockerfile working_dir: /app volumes: - ./backend/DataPlatform:/app + - ~/.m2/repository:/root/.m2/repository # Mount Maven local repository ports: - "9999:9999" environment: @@ -16,7 +17,29 @@ services: - SPRING_JPA_SHOW_SQL=true - SPRING_JPA_HIBERNATE_DDL_AUTO=create # Set the Hibernate ddl-auto property here - SPRING_JPA_GENERATE_DDL=true - #- JAVA_HOME=/usr/local/openjdk-11 + - SERVER_PORT=9999 + depends_on: + - mysql + command: mvn clean spring-boot:run -DskipTests + + app2: + restart: always + build: ./backend/DataPlatform/FlinkRestService # backend dockerfile + working_dir: /app + volumes: + - ./backend/DataPlatform:/app + - ~/.m2/repository:/root/.m2/repository # Mount Maven local repository + ports: + - "9998:9998" # Port mapping for app2 + environment: + - SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/data_platform + - SPRING_DATASOURCE_USERNAME=root + - SPRING_DATASOURCE_PASSWORD= + - SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.cj.jdbc.Driver + - SPRING_JPA_SHOW_SQL=true + - SPRING_JPA_HIBERNATE_DDL_AUTO=create # Set the Hibernate ddl-auto property here + - SPRING_JPA_GENERATE_DDL=true + - SERVER_PORT=9998 depends_on: - mysql command: mvn clean spring-boot:run -DskipTests @@ -35,8 +58,6 @@ services: image: mysql:5.7 restart: always environment: - #https://stackoverflow.com/questions/66831863/mysql-docker-container-keeps-restarting - #MYSQL_USER: root # NO NEED to create root user, since it is created automatically MYSQL_DATABASE: data_platform MYSQL_ROOT_PASSWORD: MYSQL_ALLOW_EMPTY_PASSWORD: "yes" @@ -49,14 +70,13 @@ services: image: nginx restart: always ports: - #- "8080:80" - "8081:8081" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/index.html:/app/html:ro depends_on: - - app - #- app2 + - app1 + - app2 volumes: mysql-data: \ No newline at end of file diff --git a/SpringDataPlatform/nginx/nginx.conf b/SpringDataPlatform/nginx/nginx.conf index 6761e0140..d05a9e78b 100644 --- a/SpringDataPlatform/nginx/nginx.conf +++ b/SpringDataPlatform/nginx/nginx.conf @@ -12,8 +12,8 @@ http { keepalive_timeout 65; upstream dataPlatform { - server app:9999; - #server app2:9998; + server app1:9999; + server app2:9998; } server {