Skip to content

Commit c251644

Browse files
Missed some file from commit of docker support for mysql, react-ui and common-data-service
1 parent dabbd42 commit c251644

File tree

15 files changed

+175
-10
lines changed

15 files changed

+175
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
.env
4+
35
# Client
46
# dependencies
57
/client/node_modules

client/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

client/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ WORKDIR /usr/src/app
99
# Install app dependencies
1010
# A wildcard is used to ensure both package.json AND package-lock.json are copied
1111
# where available (npm@5+)
12-
COPY package*.json ./
12+
COPY ./client/package*.json ./
1313

1414
RUN npm install
1515

1616
# Bundle app source
1717
COPY . .
1818

19+
#RUN yarn install
20+
1921
# Initiate npm start
2022
CMD [ "npm", "start" ]

client/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
"swiper": "^5.4.2"
3535
},
3636
"scripts": {
37-
"start": "env-cmd -f .env react-scripts start",
38-
"build": "env-cmd -f .env react-scripts build",
37+
"start": "react-scripts start",
38+
"build": "react-scripts build",
39+
"start_dev": "./node_modules/.bin/env-cmd -f .env react-scripts start",
40+
"build_dev": "./node_modules/.bin/env-cmd -f .env react-scripts build",
3941
"test": "react-scripts test",
4042
"eject": "react-scripts eject"
4143
},

client/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Only files inside the `public` folder can be referenced from the HTML.
2323
2424
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
25-
work correctly both with react-ui-side routing and a non-root public URL.
25+
work correctly both with client-side routing and a non-root public URL.
2626
Learn how to configure a non-root public URL by running `npm run build`.
2727
-->
2828
<title>React App</title>

client/src/api/service_api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import axios from 'axios';
22

3+
const {REACT_APP_COMMON_DATA_SERVICE_IP, REACT_APP_COMMON_DATA_SERVICE_PORT} = process.env
4+
35
export const paymentServiceAPI = axios.create({
46
baseURL: 'http://localhost:9050'
57
})
@@ -9,5 +11,5 @@ export const authServiceAPI = axios.create({
911
})
1012

1113
export const commonServiceAPI = axios.create({
12-
baseURL: 'http://localhost:9000'
14+
baseURL: `http://${REACT_APP_COMMON_DATA_SERVICE_IP}:${REACT_APP_COMMON_DATA_SERVICE_PORT}`
1315
})

client/src/components/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {CancelPayment} from "./routes/cancelPayment";
1616
import {BadRequest} from "./ui/error/badRequest";
1717

1818
const App = () => {
19-
log.info(`[App]: Rendering App Component window`)
19+
log.info(`[App]: Rendering App Component`)
2020

2121
return (
2222
<Router history={history}>

docker-compose.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
version: '3'
2+
3+
services:
4+
mysql-db:
5+
image: mysql:8
6+
container_name: mysql-db-container
7+
environment:
8+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
9+
MYSQL_DATABASE: ${MYSQL_DATABASE}
10+
MYSQL_USER: ${MYSQL_USER}
11+
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
12+
volumes:
13+
- ./mysql-db/user.sql:/docker-entrypoint-initdb.d/user.sql
14+
ports:
15+
- 3312:3306
16+
networks:
17+
- spring-cloud-microservices
18+
19+
common-data-service:
20+
build:
21+
context: .
22+
dockerfile: ./server/common-data-service/Dockerfile
23+
container_name: common-data-service-container
24+
restart: always
25+
depends_on:
26+
- mysql-db
27+
- react-ui
28+
environment:
29+
- DB_HOST=${DB_HOST}
30+
- DB_PORT=${DB_PORT}
31+
- DB_USER=${DB_USER}
32+
- DB_PASS=${DB_PASS}
33+
- DB_SCHEMA=${DB_SCHEMA}
34+
- ACTIVE_PROFILE=${ACTIVE_PROFILE}
35+
- COMMON_DATA_SERVICE_PORT=${COMMON_DATA_SERVICE_PORT}
36+
links:
37+
- mysql-db:mysql
38+
expose:
39+
- ${COMMON_DATA_SERVICE_PORT}
40+
ports:
41+
- ${COMMON_DATA_SERVICE_PORT}:${COMMON_DATA_SERVICE_PORT}
42+
networks:
43+
- spring-cloud-microservices
44+
45+
react-ui:
46+
build:
47+
context: .
48+
dockerfile: ./client/Dockerfile
49+
container_name: react-service-container
50+
stdin_open: true
51+
restart: always
52+
expose:
53+
- ${REACTT_APP_PORT}
54+
ports:
55+
- ${REACTT_APP_PORT}:${REACTT_APP_PORT}
56+
environment:
57+
- REACT_APP_STRIPE_PUBLISH_KEY=${REACT_APP_STRIPE_PUBLISH_KEY}
58+
- REACT_APP_COMMON_DATA_SERVICE_IP=${REACT_APP_COMMON_DATA_SERVICE_IP}
59+
- REACT_APP_COMMON_DATA_SERVICE_PORT=${COMMON_DATA_SERVICE_PORT}
60+
volumes:
61+
- ./client:/usr/src/app
62+
- /usr/src/app/node_modules
63+
depends_on:
64+
- mysql-db
65+
networks:
66+
- spring-cloud-microservices
67+
networks:
68+
spring-cloud-microservices:
69+
external: true

mysql-db/user.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GRANT ALL PRIVILEGES ON *.* TO 'springstudent'@'%';

server/common-data-service/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Docker multi-stage build
2+
3+
# 1. Building the App with Maven
4+
FROM maven:3-jdk-11
5+
6+
ADD ./server/common-data-service /common_data_service_staging
7+
8+
WORKDIR /common_data_service_staging
9+
10+
# Just echo so we can see, if everything is there
11+
RUN ls -l
12+
13+
# Run Maven build
14+
RUN mvn clean install -DskipTests
15+
16+
# 2. Just using the build artifact and then removing the build-container
17+
FROM openjdk:11-jdk
18+
19+
VOLUME /tmp
20+
21+
# Add Spring Boot app.jar to Container
22+
COPY --from=0 /common_data_service_staging/target/common-data-service.jar common-data-service.jar
23+
24+
# Fire up our Spring Boot app by default
25+
CMD ["sh", "-c", "java -Dserver.port=$COMMON_DATA_SERVICE_PORT -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 -XX:+UseContainerSupport -Dspring.profiles.active=$ACTIVE_PROFILE -Djava.security.egd=file:/dev/./urandom -jar common-data-service.jar" ]
26+

0 commit comments

Comments
 (0)