mirror of https://gitlab.com/ecentrics/concordia
Apostolos Fanakis
4 years ago
11 changed files with 147 additions and 13 deletions
@ -0,0 +1,34 @@ |
|||||
|
# -------------------------------------------------- |
||||
|
# Stage 1 (Runtime) |
||||
|
# -------------------------------------------------- |
||||
|
FROM node:14-buster as runtime |
||||
|
LABEL maintainers.1="Apostolos Fanakis <apostolof@auth.gr>" |
||||
|
LABEL maintainers.2="Panagiotis Nikolaidis <ezerous@gmail.com>" |
||||
|
LABEL gr.thmmy.ecentrics.concordia-image.name="pinner" |
||||
|
|
||||
|
# Fix timezome (needed for timestamps on report files) |
||||
|
ARG TZ |
||||
|
ENV TZ=${TZ} |
||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
||||
|
|
||||
|
WORKDIR /usr/src/concordia |
||||
|
|
||||
|
# Copy the root package.json and yarn.lock |
||||
|
COPY ./package.json . |
||||
|
COPY ./yarn.lock . |
||||
|
|
||||
|
# Copy the pinner, contracts and shared package.json files, then install modules |
||||
|
COPY ./packages/concordia-pinner/package.json ./packages/concordia-pinner/ |
||||
|
COPY ./packages/concordia-contracts/package.json ./packages/concordia-contracts/ |
||||
|
COPY ./packages/concordia-shared/package.json ./packages/concordia-shared/ |
||||
|
|
||||
|
RUN yarn install --frozen-lockfile --network-timeout 100000 |
||||
|
|
||||
|
# Gets the rest of the source code |
||||
|
COPY ./packages/concordia-shared ./packages/concordia-shared |
||||
|
COPY ./packages/concordia-contracts ./packages/concordia-contracts |
||||
|
COPY ./packages/concordia-pinner ./packages/concordia-pinner |
||||
|
|
||||
|
WORKDIR /usr/src/concordia/packages/concordia-pinner |
||||
|
|
||||
|
ENTRYPOINT ["yarn", "start"] |
@ -0,0 +1,16 @@ |
|||||
|
USE_EXTERNAL_CONTRACTS_PROVIDER=true |
||||
|
ORBIT_DIRECTORY=/data/orbitdb |
||||
|
|
||||
|
#CONTRACTS_PROVIDER_HOST=contracts-provider |
||||
|
CONTRACTS_PROVIDER_HOST=127.0.0.1 |
||||
|
CONTRACTS_PROVIDER_PORT=8400 |
||||
|
CONTRACTS_VERSION_HASH=latest |
||||
|
|
||||
|
PINNER_API_HOST=127.0.0.1 |
||||
|
PINNER_API_PORT=4444 |
||||
|
|
||||
|
RENDEZVOUS_HOST=127.0.0.1 |
||||
|
RENDEZVOUS_PORT=9090 |
||||
|
|
||||
|
WEB3_HOST=127.0.0.1 |
||||
|
WEB3_PORT=8545 |
@ -0,0 +1,50 @@ |
|||||
|
import unirest from 'unirest'; |
||||
|
import { |
||||
|
contractsProviderHost, |
||||
|
contractsProviderPort, |
||||
|
contractsVersionHash, |
||||
|
} from 'concordia-shared/src/environment/interpolated/contractsProvider'; |
||||
|
import { pinnerApiHost, pinnerApiPort } from 'concordia-shared/src/environment/interpolated/pinner'; |
||||
|
import { FORUM_CONTRACT } from 'concordia-shared/src/constants/contracts/ContractNames'; |
||||
|
|
||||
|
function getContractsDownloadRequest() { |
||||
|
const HOST = pinnerApiHost; |
||||
|
const PORT = pinnerApiPort; |
||||
|
|
||||
|
return unirest( |
||||
|
'GET', |
||||
|
`http://${contractsProviderHost}:${contractsProviderPort}/contracts/${contractsVersionHash}`, |
||||
|
).headers({ |
||||
|
'Access-Control-Allow-Origin': `${HOST}:${PORT}`, |
||||
|
'Access-Control-Allow-Credentials': 'true', |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
const validateRemoteContracts = (remoteContracts) => { |
||||
|
if (!remoteContracts |
||||
|
.map((remoteContract) => remoteContract.contractName) |
||||
|
.includes(FORUM_CONTRACT)) { |
||||
|
throw new Error('Forum contract is missing from artifacts.'); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const downloadContractArtifacts = () => { |
||||
|
const request = getContractsDownloadRequest(); |
||||
|
|
||||
|
return new Promise((resolve, reject) => request |
||||
|
.end((response) => { |
||||
|
if (response.error) { |
||||
|
reject(new Error(`Remote contract artifacts download request failed!\n${response.error}`)); |
||||
|
} |
||||
|
|
||||
|
resolve(response.raw_body); |
||||
|
})).then((contractsRawData) => { |
||||
|
const remoteContracts = JSON.parse(contractsRawData); |
||||
|
|
||||
|
validateRemoteContracts(remoteContracts); |
||||
|
|
||||
|
return remoteContracts; |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
export default downloadContractArtifacts; |
@ -1,12 +1,15 @@ |
|||||
const { |
const { |
||||
pinner: { |
pinner: { |
||||
|
host: PINNER_API_HOST_DEFAULT, |
||||
port: PINNER_API_PORT_DEFAULT, |
port: PINNER_API_PORT_DEFAULT, |
||||
}, |
}, |
||||
} = require('../../constants/configuration/defaults'); |
} = require('../../constants/configuration/defaults'); |
||||
const { pinnerApiPortEnv } = require('../pinnerEnv'); |
const { pinnerApiHostEnv, pinnerApiPortEnv } = require('../pinnerEnv'); |
||||
|
|
||||
|
const pinnerApiHost = pinnerApiHostEnv || PINNER_API_HOST_DEFAULT; |
||||
const pinnerApiPort = pinnerApiPortEnv || PINNER_API_PORT_DEFAULT; |
const pinnerApiPort = pinnerApiPortEnv || PINNER_API_PORT_DEFAULT; |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
|
pinnerApiHost, |
||||
pinnerApiPort, |
pinnerApiPort, |
||||
}; |
}; |
||||
|
@ -1,7 +1,9 @@ |
|||||
// Depending on the package user (app in contrast to any of the other packages) the env var names should either include
|
// Depending on the package user (app in contrast to any of the other packages) the env var names should either include
|
||||
// the REACT_APP_ prefix or not
|
// the REACT_APP_ prefix or not
|
||||
|
const pinnerApiHostEnv = process.env.REACT_APP_PINNER_API_HOST || process.env.PINNER_API_HOST; |
||||
const pinnerApiPortEnv = process.env.REACT_APP_PINNER_API_PORT || process.env.PINNER_API_PORT; |
const pinnerApiPortEnv = process.env.REACT_APP_PINNER_API_PORT || process.env.PINNER_API_PORT; |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
|
pinnerApiHostEnv, |
||||
pinnerApiPortEnv, |
pinnerApiPortEnv, |
||||
}; |
}; |
||||
|
Loading…
Reference in new issue