diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ade7af5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:alpine + +WORKDIR /app + +RUN apk update && apk add python g++ make openssh git bash pdftk +RUN export PYTHONPATH=${PYTHONPATH}:/usr/lib/python2.7 + +COPY ./package.json yarn.lock ./ + +RUN yarn + +COPY . . + +# Frontend is exposing 3000 +# Backend is exposing 8080 +# No need for expose, if using docker-compose & docker run -p 3000:3000 diff --git a/README.md b/README.md index f91f933..0f8b8bd 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,14 @@ yarn start:frontend ./target/debug/polkadot --dev --telemetry-url ws://localhost:1024 ``` +### Run via Docker +To run via docker make sure that you have Docker Desktop + - If you dont you can download for you OS here [Docker Desktop](https://www.docker.com/products/docker-desktop) +``` +docker-compose up --build -d +``` + - -d stands for detach, if you would like to see logs i recommend using [Kitmatic](https://kitematic.com/) or dont use the -d + - --build will build the images and rebuild, but this is not required everytime + - If you want to makes UI changes, there is no need to rebuild the image as the files are being copied in via volumes. + Now navigate to localhost:3000 in your browser to view the app. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5a098c2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: "3" + +services: + telemetry-frontend: + build: + dockerfile: Dockerfile + context: ./ + # Copy in changes to the ui, so no need to rebulld the images. + volumes: + - /app/node_modules + - ./packages:/app/packages + command: yarn start:frontend + ports: + - 3000:3000 + telemetry-backend: + build: + dockerfile: Dockerfile + context: ./ + command: yarn start:backend + environment: + - TELEMETRY_SERVER=1024 + - FEED_SERVER=8080 + ports: + - 8080:8080 + - 1024:1024 diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index e2230a0..65e19ca 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -3,8 +3,8 @@ import Node from './Node'; import Feed from './Feed'; import Aggregator from './Aggregator'; -const WS_PORT_TELEMETRY_SERVER = 1024; -const WS_PORT_FEED_SERVER = 8080; +const WS_PORT_TELEMETRY_SERVER = process.env.TELEMETRY_SERVER || 1024; +const WS_PORT_FEED_SERVER = process.env.FEED_SERVER || 8080; const aggregator = new Aggregator(); @@ -47,4 +47,3 @@ logClients(); telemetryFeed.on('connection', (socket: WebSocket) => { aggregator.addFeed(new Feed(socket)); }); -