diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..41774e5 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,47 @@ +FROM node:11-alpine +LABEL maintainer="Ocean Protocol " + +RUN apk add --no-cache --update\ + bash\ + g++\ + gcc\ + git\ + gettext\ + make\ + python + +COPY . /app/frontend +WORKDIR /app/frontend + +RUN npm install -g npm serve +RUN npm install + +# Default ENV values +# src/config/config.ts +ENV SERVICE_SCHEME='http' +ENV SERVICE_HOST='localhost' +ENV SERVICE_PORT='4000' +ENV NODE_SCHEME='http' +ENV NODE_HOST='localhost' +ENV NODE_PORT='8545' +ENV AQUARIUS_SCHEME='http' +ENV AQUARIUS_HOST='localhost' +ENV AQUARIUS_PORT='5000' +ENV BRIZO_SCHEME='http' +ENV BRIZO_HOST='localhost' +ENV BRIZO_PORT='8030' +ENV BRIZO_ADDRESS='0x00bd138abd70e2f00903268f3db08f2d25677c9e' +ENV PARITY_SCHEME='http' +ENV PARITY_HOST='localhost' +ENV PARITY_PORT='8545' +ENV SECRET_STORE_SCHEME='http' +ENV SECRET_STORE_HOST='localhost' +ENV SECRET_STORE_PORT='12001' +ENV FAUCET_SCHEME='http' +ENV FAUCET_HOST='localhost' +ENV FAUCET_PORT='3001' + +ENV LISTEN_ADDRESS='0.0.0.0' +ENV LISTEN_PORT='3000' + +ENTRYPOINT ["/app/frontend/scripts/docker-entrypoint.sh"] diff --git a/client/scripts/docker-entrypoint.sh b/client/scripts/docker-entrypoint.sh new file mode 100755 index 0000000..700e873 --- /dev/null +++ b/client/scripts/docker-entrypoint.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +SERVICE_SCHEME=${SERVICE_SCHEME:-http} +SERVICE_HOST=${SERVICE_HOST:-localhost} +SERVICE_PORT=${SERVICE_PORT:-8545} + +NODE_SCHEME=${NODE_SCHEME:-http} +NODE_HOST=${NODE_HOST:-localhost} +NODE_PORT=${NODE_PORT:-8545} +AQUARIUS_SCHEME=${AQUARIUS_SCHEME:-http} +AQUARIUS_HOST=${AQUARIUS_HOST:-localhost} +AQUARIUS_PORT=${AQUARIUS_PORT:-5000} +BRIZO_SCHEME=${BRIZO_SCHEME:-http} +BRIZO_HOST=${BRIZO_HOST:-localhost} +BRIZO_PORT=${BRIZO_PORT:-8030} +BRIZO_PASSWORD=${BRIZO_PASSWORD:-0x00bd138abd70e2f00903268f3db08f2d25677c9e} +PARITY_SCHEME=${PARITY_SCHEME:-http} +PARITY_HOST=${PARITY_HOST:-localhost} +PARITY_PORT=${PARITY_PORT:-8545} +SECRET_STORE_SCHEME=${SECRET_STORE_SCHEME:-http} +SECRET_STORE_HOST=${SECRET_STORE_HOST:-localhost} +SECRET_STORE_PORT=${SECRET_STORE_PORT:-12001} + +FAUCET_SCHEME=${FAUCET_SCHEME:-http} +FAUCET_HOST=${FAUCET_HOST:-localhost} +FAUCET_PORT=${FAUCET_PORT:-443} + +envsubst < /app/frontend/src/config/config.ts.template > /app/frontend/src/config/config.ts +if [ "${LOCAL_CONTRACTS}" = "true" ]; then + echo "Waiting for contracts to be generated..." + while [ ! -f "/app/frontend/node_modules/@oceanprotocol/keeper-contracts/artifacts/ready" ]; do + sleep 2 + done +fi +echo "Starting Commons..." +npm run build +serve -l tcp://"${LISTEN_ADDRESS}":"${LISTEN_PORT}" -s /app/frontend/build/ diff --git a/client/src/App.tsx b/client/src/App.tsx index 63cb397..fc318f2 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -18,7 +18,7 @@ import { faucetHost, faucetPort, faucetScheme -} from './config' +} from './config/config' declare global { interface Window { diff --git a/client/src/config.ts b/client/src/config/config.ts similarity index 100% rename from client/src/config.ts rename to client/src/config/config.ts diff --git a/client/src/config/config.ts.template b/client/src/config/config.ts.template new file mode 100644 index 0000000..120aad8 --- /dev/null +++ b/client/src/config/config.ts.template @@ -0,0 +1,36 @@ +// +// commons-server connection +// +export const serviceScheme = '${SERVICE_SCHEME}' +export const serviceHost = '${SERVICE_HOST}' +export const servicePort = '${SERVICE_PORT}' + +// +// OCEAN REMOTE CONNECTIONS +// +export const nodeScheme = '${NODE_SCHEME}' +export const nodeHost = '${NODE_HOST}' +export const nodePort = '${NODE_PORT}' + +export const aquariusScheme = '${AQUARIUS_SCHEME}' +export const aquariusHost = '${AQUARIUS_HOST}' +export const aquariusPort = '${AQUARIUS_PORT}' + +export const brizoScheme = '${BRIZO_SCHEME}' +export const brizoHost = '${BRIZO_HOST}' +export const brizoPort = '${BRIZO_ADDRESS}' +export const brizoAddress = '${BRIZO_ADDRESS}' + +export const parityScheme = '${PARITY_SCHEME}' +export const parityHost = '${PARITY_HOST}' +export const parityPort = '${PARITY_PORT}' + +export const secretStoreScheme = '${SECRET_STORE_SCHEME}' +export const secretStoreHost = '${SECRET_STORE_HOST}' +export const secretStorePort = '${SECRET_STORE_PORT}' + +export const faucetScheme = '${FAUCET_SCHEME}' +export const faucetHost = '${FAUCET_HOST}' +export const faucetPort = '${FAUCET_PORT}' + +export const verbose = true diff --git a/client/src/ocean.ts b/client/src/ocean.ts index 1d70dbb..f2fc95d 100644 --- a/client/src/ocean.ts +++ b/client/src/ocean.ts @@ -18,7 +18,7 @@ import { secretStorePort, secretStoreScheme, verbose -} from './config' +} from './config/config' export async function provideOcean() { const nodeUri = `${nodeScheme}://${nodeHost}:${nodePort}` diff --git a/client/src/routes/Publish/Files/index.tsx b/client/src/routes/Publish/Files/index.tsx index f7a566b..9794584 100644 --- a/client/src/routes/Publish/Files/index.tsx +++ b/client/src/routes/Publish/Files/index.tsx @@ -6,7 +6,7 @@ import ItemForm from './ItemForm' import Item from './Item' import styles from './index.module.scss' -import { serviceHost, servicePort, serviceScheme } from '../../../config' +import { serviceHost, servicePort, serviceScheme } from '../../../config/config' interface File { url: string diff --git a/client/tsconfig.json b/client/tsconfig.json index 2f4d2c3..ecfa1c2 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -15,5 +15,5 @@ "noEmit": true, "jsx": "preserve" }, - "include": ["src"] + "include": ["src", "config/config.ts"] } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b9296b3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3.4' + +services: + + client: + build: + context: ./client + dockerfile: ./Dockerfile + ports: + - 3000:3000 + depends_on: + - server + environment: + - SERVICE_SCHEME=http + - SERVICE_HOST=localhost + - SERVICE_PORT=4000 + + server: + build: + context: ./server + dockerfile: ./Dockerfile + ports: + - 4000:4000 + command: npm run start diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..56b621f --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,10 @@ +FROM node:11-alpine +LABEL maintainer="Ocean Protocol " + +WORKDIR /app/backend/ + +COPY . . + +RUN npm install + +RUN npm run build