Code Monkey home page Code Monkey logo

report-generator-with-react's Introduction

report-generator-with-react

  • R/Pythonで生成したhtmlを管理するSPAを作成するコンテナ(Docker使用)+app
  • Flask or react でPOSTされるhtmlの受け口を作る -> 将来的にはshinyで作りたい
  • 雑なメモ: https://hackmd.io/crhgugtYTouUUFKa5qJ7hg

コンテナ

この作業は、report-generator-with-reactでの作業

react

build

  • Docker/Dockerfileからのbuild
docker build -t reporter-react:0.0 -f Docker/react/Dockerfile .

run

  • 作成したreporter-react:<tag>で実行
    • -it: フォワードで、ターミナル起動
    • --rm: コンテナが終了後削除
    • -v <path>/report-generator-with-react/:/home/repo: /home/repoにこのレポジトリをマウント(はgitのフォルダを指定)
    • -p 8990:3000: 端末の8990をコンテナの3000にポートフォワード
docker run -it -v $PWD:/home/repo -p 8990:3000 --rm reporter-react:0.0 /bin/bash
  • docker-composeでの実行
docker-compose -f Docker/react/docker-compose.yml up -d

nginx

build

  • Docker/Dockerfile-nginxからのbuild
docker build -t reporter-nginx:0.0 -f Docker/nginx/Dockerfile .

run

  • reactでbuildしたフォルダとreportのフォルダを覗かせる
docker run --rm -v $PWD/react-reporter/build:/usr/share/nginx/html -v $PWD/report:/mnt/report --name nginx-reporter -p 8991:80 reporter-nginx:0.0

httpd(apache)

  • Docker/Dockerfile-httpdからのbuild
docker build -t reporter-httpd:0.0 -f Docker/httpd/Dockerfile .
  • reactでbuildしたフォルダとreportのフォルダを覗かせる
    • はgitのフォルダを指定
docker run --rm -v <PATH>/report-generator-with-react/react-reporter/build:/usr/share/ -v <PATH>/report-generator-with-react/report:/mnt/report -p 8991:80 reporter-nginx:0.0

MySQL

  • レポートのタグを保存する
docker run --rm --name reporter-mysql -e MYSQL_ROOT_PASSWORD=mysql -p 8992:3306 -d -it mysql:8.0.20
mysql -u root -p -h localhost -P 8992 --protocol=tcp

create table maps (name varchar(50), url varchar(100));
insert into maps values("test_rmarkdown", "http://localhost:8991/report/test_rmarkdown.html");
  • docker-composeで行う(成功済み)
docker-compose -f Docker/mysql/docker-compose.yml up --build
  • docker-compose内で以下のように設定したので、mysqlコンテナ内のデータは、/mysql/dataに保存される
    volumes: 
      - $PWD/mysql/data:/var/lib/mysql
(base) ➜  report-generator-with-react git:(master) ✗ tree mysql -d 2  
mysql
├── conf
├── data
│   ├── #innodb_temp
│   ├── mysql
│   ├── performance_schema
│   ├── reporter
│   └── sys
└── init

Flask

  • POSTを受け取る > mysqlに必要なデータを保存 + htmlレポート復元
docker build -t reporter-flask:0.0 -f Docker/flask/Dockerfile .

docker-compose.ymlにまとめる

docker-compose -f Docker/docker-compose.yml up -d --build

アプリケーション

react app

  • appの生成(npx: 最新だとこっちみたい。nodeとnpmのversion upが必要)
    • npm create-react-appと比べて、設定ファイルが増えている
    • public/manifest.jsonはホーム画面へ追加する際に、より細かな指定をするための記述
npx create-react-app react-reporter
  • appの起動(デフォルトだと3000)
cd react-reporter
npm start
  • build:静的ページの生成
    • これをapache or nginxで覗かせるかなー
npm run build

flaskで受け取る

nginxで公開

  • 例えば、これでアクセスできる
http://localhost:8991/report/test_rmarkdown.html

mysqlに接続

  • localhostだと探せない
mysql -u root -h 127.0.0.1 -P 8993 -p

report-generator-with-react's People

Contributors

kbttik avatar

Watchers

 avatar  avatar

report-generator-with-react's Issues

mysqlにテーブル作る

  • 必要なテーブル
  • tags: レポートとtagの紐付け。
id tag
report番号 タグ
  • reports
id URL title create_at
report番号 nginxの公開用URL レポートタイトル POSTされた日

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.