Skip to content

Commit

Permalink
Merge pull request #390 from longxiaofei/master
Browse files Browse the repository at this point in the history
chore: update docker-compose.yml
  • Loading branch information
ObservedObserver authored Aug 25, 2023
2 parents 9c5b613 + 01d5cbf commit 9782aa0
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 12 deletions.
55 changes: 55 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

/server/dataset/

.vscode

safety
dist

coverage

.cache
.eslintcache

*.cert
*.key
*.pem

packages/frontend/public/datasets/*

*service.json
*.db

for_test/
sasl-0.3.1-cp310-cp310-win_amd64.whl
__pycache__/
.idea/
connect.db
not_sqlalchemy/
run_flask_app.bat
venv

dataset-with-metas.json
20 changes: 12 additions & 8 deletions client.dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM node:16 as build-stage
FROM node:16 AS build-stage

COPY . /app

WORKDIR /app
ENV NODE_OPTIONS=--max_old_space_size=4096
RUN npm config set registry https://registry.npmmirror.com
RUN yarn config set registry https://registry.npmmirror.com

RUN yarn install
RUN yarn workspace rath-client build2

FROM nginx:latest
COPY --from=build-stage /app/packages/rath-client/build /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
RUN yarn workspace rath-client buildOnDocker

FROM nginx:1.24

COPY --from=node-builder /app/packages/rath-client/build /usr/share/nginx/html
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf

ENTRYPOINT ["nginx", "-g", "daemon off;"]
21 changes: 19 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
version: "2"

services:
frontend:
base:
restart: always
build:
context: .
dockerfile: client.dockerfile
ports:
- 8080:80
- 9083:80

connector-api:
restart: always
network_mode: service:base
build:
context: ./services/connector
dockerfile: Dockerfile

prediction-api:
restart: always
network_mode: service:base
build:
context: ./services/prediction
dockerfile: Dockerfile
23 changes: 23 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location /connector/api {
proxy_pass http://localhost:5001/api;
}

location /api/train_test {
proxy_pass http://localhost:5533/api/train_test;
}

}
1 change: 1 addition & 0 deletions packages/rath-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"build:renderer": "yarn workspace vega-painter-renderer build",
"start": "react-app-rewired start",
"build": "npm run build:utils && npm run build:scenegraph && npm run build:renderer && npm run build:client",
"buildOnDocker": "npm run build:utils && npm run build:scenegraph && npm run build:renderer && GENERATE_SOURCEMAP=false react-app-rewired --max_old_space_size=4096 build",
"build:client": "GENERATE_SOURCEMAP=false react-app-rewired --max_old_space_size=8000 build",
"buildForAnalysis": "react-app-rewired build",
"test": "jest -c ./jest.config.js --passWithNoTests --no-cache",
Expand Down
2 changes: 1 addition & 1 deletion packages/rath-client/src/pages/causal/predict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface IPredictResult {
const PREDICT_API_KEY = 'prediction_service';
function getPredictAPIPath (path = "/api/train_test") {
const baseURL = new URL(window.location.href);
const serviceURL = new URL(baseURL.searchParams.get(PREDICT_API_KEY) || localStorage.getItem(PREDICT_API_KEY) || "http://127.0.0.1:5533/api/train_test");
const serviceURL = new URL(baseURL.searchParams.get(PREDICT_API_KEY) || localStorage.getItem(PREDICT_API_KEY) || window.location.href);
serviceURL.pathname = path;
return serviceURL.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ interface DatabaseDataProps {
export const inputWidth = '180px';

export const defaultServers: readonly string[] = [
"/connector",
'https://gateway.kanaries.net/connector',
'https://kanaries.cn/connector',
];

const MAX_SERVER_COUNT = 5;
Expand Down
9 changes: 9 additions & 0 deletions services/prediction/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.10.7

WORKDIR /prediction

COPY . /prediction

RUN pip3 install --trusted-host pypi.python.org -r requirements.txt

CMD python3 -u /prediction/main.py
6 changes: 6 additions & 0 deletions services/prediction/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Flask
Flask_cors
gevent
scikit-learn==1.3.0
xgboost==1.7.6
pandas==2.0.3

1 comment on commit 9782aa0

@vercel
Copy link

@vercel vercel bot commented on 9782aa0 Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.