mirror of https://gitlab.com/ecentrics/concordia
Apostolos Fanakis
4 years ago
66 changed files with 1321 additions and 213 deletions
@ -0,0 +1,14 @@ |
|||
#!/bin/sh |
|||
|
|||
echo "window.runtimeEnv = { \ |
|||
REACT_APP_CONCORDIA_HOST: \"${REACT_APP_CONCORDIA_HOST}\", \ |
|||
REACT_APP_CONCORDIA_PORT: \"${REACT_APP_CONCORDIA_PORT}\", \ |
|||
REACT_APP_WEB3_HOST: \"${REACT_APP_WEB3_HOST}\", \ |
|||
REACT_APP_WEB3_PORT: \"${REACT_APP_WEB3_PORT}\", \ |
|||
REACT_APP_RENDEZVOUS_HOST: \"${REACT_APP_RENDEZVOUS_HOST}\", \ |
|||
REACT_APP_RENDEZVOUS_PORT: \"${REACT_APP_RENDEZVOUS_PORT}\", \ |
|||
REACT_APP_USE_EXTERNAL_CONTRACTS_PROVIDER: \"${REACT_APP_USE_EXTERNAL_CONTRACTS_PROVIDER}\", \ |
|||
REACT_APP_CONTRACTS_PROVIDER_HOST: \"${REACT_APP_CONTRACTS_PROVIDER_HOST}\", \ |
|||
REACT_APP_CONTRACTS_PROVIDER_PORT: \"${REACT_APP_CONTRACTS_PROVIDER_PORT}\", \ |
|||
REACT_APP_CONTRACTS_VERSION_HASH: \"${REACT_APP_CONTRACTS_VERSION_HASH}\", \ |
|||
}" >/var/www/concordia-app/environment.js |
@ -0,0 +1,3 @@ |
|||
sh /opt/concordia/create-environment.sh |
|||
|
|||
exec "$(which nginx)" -g "daemon off;" |
@ -0,0 +1,36 @@ |
|||
# -------------------------------------------------- |
|||
# Stage 1 (Runtime) |
|||
# -------------------------------------------------- |
|||
FROM node:14-alpine@sha256:51e341881c2b77e52778921c685e711a186a71b8c6f62ff2edfc6b6950225a2f 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="contracts-provider" |
|||
|
|||
# Fix timezome (needed for timestamps on report files) |
|||
ARG TZ |
|||
|
|||
RUN apk add -U tzdata \ |
|||
&& cp /usr/share/zoneinfo/$TZ /etc/localtime \ |
|||
&& echo $TZ > /etc/timezone \ |
|||
&& apk del tzdata \ |
|||
&& rm -rf /var/cache/apk/* |
|||
|
|||
WORKDIR /usr/src/concordia |
|||
|
|||
# Copy the root package.json and yarn.lock |
|||
COPY ./package.json . |
|||
COPY ./yarn.lock . |
|||
|
|||
# Copy package.json files from shared and contracts provider, then install modules |
|||
COPY ./packages/concordia-shared/package.json ./packages/concordia-shared/ |
|||
COPY ./packages/concordia-contracts-provider/package.json ./packages/concordia-contracts-provider/ |
|||
|
|||
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-provider ./packages/concordia-contracts-provider |
|||
|
|||
WORKDIR /usr/src/concordia/packages/concordia-contracts-provider |
|||
|
|||
ENTRYPOINT ["yarn", "start"] |
@ -1,7 +0,0 @@ |
|||
# Variables needed in runtime (in browser) |
|||
REACT_APP_RENDEZVOUS_HOST=rendezvous |
|||
REACT_APP_RENDEZVOUS_PORT=9090 |
|||
|
|||
# If the rendezvous server is running on host use these instead |
|||
#REACT_APP_RENDEZVOUS_HOST=127.0.0.1 |
|||
#REACT_APP_RENDEZVOUS_PORT=9090 |
@ -0,0 +1,4 @@ |
|||
# Variables needed in runtime (in browser) |
|||
REACT_APP_RENDEZVOUS_HOST=127.0.0.1 |
|||
REACT_APP_RENDEZVOUS_PORT=9090 |
|||
USE_EXTERNAL_CONTRACTS_PROVIDER=true |
@ -1,20 +0,0 @@ |
|||
# Set to "CI" if in CI environment, anything else (including unset) will be ignored |
|||
BUILD_ENV={CI} |
|||
|
|||
# Docker compose variables |
|||
VIRTUAL_HOST=example.com |
|||
VIRTUAL_PORT=3000 |
|||
|
|||
# If you uncomment the lines below, Concordia will become available through https BUT the rendezvous |
|||
# server will stop working and IPFS initialization won't complete |
|||
#LETSENCRYPT_HOST=example.com |
|||
#LETSENCRYPT_EMAIL=someemail.email.com |
|||
|
|||
# Variables needed in runtime |
|||
# TO-NEVER-DO: change CONCORDIA_HOST to localhost |
|||
CONCORDIA_HOST=0.0.0.0 |
|||
CONCORDIA_PORT=3000 |
|||
|
|||
# Variables needed in runtime (in browser) |
|||
REACT_APP_RENDEZVOUS_HOST=xx.xxx.xxx.xxx |
|||
REACT_APP_RENDEZVOUS_PORT=9090 |
@ -0,0 +1 @@ |
|||
UPLOAD_CONTRACTS_DIRECTORY=/mnt/concordia/contracts/ |
@ -1,14 +0,0 @@ |
|||
# Variables needed in runtime |
|||
MIGRATE_NETWORK=env |
|||
DEPLOY_CHAIN_HOST=concordia-ganache |
|||
DEPLOY_CHAIN_PORT=8545 |
|||
|
|||
TEST_CHAIN_HOST=concordia-ganache-test |
|||
TEST_CHAIN_PORT=8546 |
|||
|
|||
# If the blockchain is running on host use these instead |
|||
#DEPLOY_CHAIN_HOST=127.0.0.1 |
|||
#DEPLOY_CHAIN_PORT=8545 |
|||
|
|||
#TEST_CHAIN_HOST=127.0.0.1 |
|||
#TEST_CHAIN_PORT=8546 |
@ -0,0 +1,10 @@ |
|||
# Variables needed in runtime |
|||
MIGRATE_NETWORK=env |
|||
WEB3_HOST=concordia-ganache |
|||
WEB3_PORT=8545 |
|||
|
|||
CONTRACTS_PROVIDER_HOST=concordia-contracts-provider |
|||
CONTRACTS_PROVIDER_PORT=8400 |
|||
|
|||
TEST_CHAIN_HOST=concordia-ganache-test |
|||
TEST_CHAIN_PORT=8546 |
@ -1,7 +0,0 @@ |
|||
# Variables needed in runtime |
|||
MIGRATE_NETWORK=env |
|||
DEPLOY_CHAIN_HOST=xx.xxx.xxx.xxx |
|||
DEPLOY_CHAIN_PORT=8545 |
|||
|
|||
TEST_CHAIN_HOST=xx.xxx.xxx.xxx |
|||
TEST_CHAIN_PORT=8545 |
@ -1,16 +1,15 @@ |
|||
USE_EXTERNAL_CONTRACTS_PROVIDER=true |
|||
ORBIT_DIRECTORY=/data/orbitdb |
|||
ORBIT_DIRECTORY=/mnt/concordia/orbitdb |
|||
|
|||
#CONTRACTS_PROVIDER_HOST=contracts-provider |
|||
CONTRACTS_PROVIDER_HOST=127.0.0.1 |
|||
CONTRACTS_PROVIDER_HOST=concordia-contracts-provider |
|||
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_HOST=concordia-rendezvous |
|||
RENDEZVOUS_PORT=9090 |
|||
|
|||
WEB3_HOST=127.0.0.1 |
|||
WEB3_HOST=concordia-ganache |
|||
WEB3_PORT=8545 |
|||
|
@ -0,0 +1,759 @@ |
|||
#!groovy |
|||
|
|||
def cleanSlateEnabled |
|||
|
|||
// Package change state |
|||
def appPackageChanged |
|||
def contractsPackageChanged |
|||
def contractsProviderPackageChanged |
|||
def pinnerPackageChanged |
|||
def sharedPackageChanged |
|||
|
|||
// Package versions |
|||
def appPackageVersion |
|||
def contractsPackageVersion |
|||
def contractsProviderPackageVersion |
|||
def pinnerPackageVersion |
|||
def sharedPackageVersion |
|||
|
|||
// Docker images |
|||
def appImage |
|||
def appTestsImage |
|||
def contractsImage |
|||
def contractsTestsImage |
|||
def contractsProviderImage |
|||
def pinnerImage |
|||
|
|||
def freshGanacheStagingRunning |
|||
def freshGanacheProductionRunning |
|||
|
|||
def successResultGif = "https://media.giphy.com/media/o75ajIFH0QnQC3nCeD/giphy.gif" |
|||
def failResultGif = "https://media.giphy.com/media/ljtfkyTD3PIUZaKWRi/giphy.gif" |
|||
def abortResultGif = "https://media.giphy.com/media/IzXmRTmKd0if6/giphy.gif" |
|||
|
|||
pipeline { |
|||
agent any |
|||
|
|||
post { |
|||
failure { |
|||
updateGitlabCommitStatus name: 'build', state: 'failed' |
|||
|
|||
discordSend footer: "Visit Jenkins for more information", result: currentBuild.currentResult, link: env.BUILD_URL, description: """Jenkins Pipeline Build |
|||
Last commit included is [${GIT_COMMIT[0..7]}](https://gitlab.com/ecentrics/concordia/-/commit/$GIT_COMMIT) |
|||
Build status: ${currentBuild.currentResult} |
|||
""", image: failResultGif, thumbnail: "$CONCORDIA_LOGO_URL", title: JOB_NAME, webhookURL: "${DISCORD_WEBHOOK_URL}" |
|||
} |
|||
success { |
|||
updateGitlabCommitStatus name: 'build', state: 'success' |
|||
|
|||
discordSend footer: "Visit Jenkins for more information", result: currentBuild.currentResult, link: env.BUILD_URL, description: """Jenkins Pipeline Build |
|||
Last commit included is [${GIT_COMMIT[0..7]}](https://gitlab.com/ecentrics/concordia/-/commit/$GIT_COMMIT) |
|||
Build status: ${currentBuild.currentResult} |
|||
""", image: successResultGif, thumbnail: "$CONCORDIA_LOGO_URL", title: JOB_NAME, webhookURL: "${DISCORD_WEBHOOK_URL}" |
|||
} |
|||
aborted { |
|||
discordSend footer: "Visit Jenkins for more information", result: currentBuild.currentResult, link: env.BUILD_URL, description: """Jenkins Pipeline Build |
|||
Last commit included is [${GIT_COMMIT[0..7]}](https://gitlab.com/ecentrics/concordia/-/commit/$GIT_COMMIT) |
|||
Build status: ${currentBuild.currentResult} |
|||
""", image: abortResultGif, thumbnail: "$CONCORDIA_LOGO_URL", title: JOB_NAME, webhookURL: "${DISCORD_WEBHOOK_URL}" |
|||
} |
|||
always { |
|||
archiveArtifacts artifacts: "reports/${BUILD_NUMBER}/**/* , build/**/*, ganache/*", fingerprint: true, allowEmptyArchive: true |
|||
sleep 2 |
|||
sh 'docker images | grep -E "ecentrics/concordia.+tests" | tr -s \' \' | cut -d \' \' -f 3 | xargs --no-run-if-empty docker rmi -f || true' |
|||
sh 'docker images | grep -E "ecentrics/concordia.+staging" | tr -s \' \' | cut -d \' \' -f 3 | xargs --no-run-if-empty docker rmi -f || true' |
|||
sh 'docker system prune -f' |
|||
sh 'rm -rf reports' |
|||
sh 'rm -rf build' |
|||
} |
|||
} |
|||
options { |
|||
gitLabConnection('apella') |
|||
} |
|||
triggers { |
|||
gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All') |
|||
} |
|||
environment { |
|||
DOCKER_BUILDKIT='1' |
|||
DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/810180975580938290/HYYeK8Nqwt0h8Arx3qPpF-szjgLkPDTqbVVKLkzcmqY7ourTpKJCAc6IuCXHd_cxowuK" |
|||
CONCORDIA_LOGO_URL="https://i.postimg.cc/MGvgy9Lp/app-logo-circle.png" |
|||
} |
|||
|
|||
stages { |
|||
stage ('VERSION') { |
|||
steps { |
|||
script { |
|||
cleanSlateEnabled = sh (script: "git log -1 | grep -qE 'ci: force'", returnStatus: true) |
|||
|
|||
appPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh app "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() |
|||
contractsPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh contracts "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() |
|||
contractsProviderPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh concordia-contracts-provider "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() |
|||
pinnerPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh pinner "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() |
|||
sharedPackageChanged = sh(script: 'bash ./jenkins/check_package_changed.sh shared "$GIT_COMMIT" "$GIT_PREVIOUS_COMMIT"', returnStdout: true).trim() |
|||
|
|||
appPackageVersion = sh(script: 'grep "\\"version\\":" ./packages/concordia-app/package.json | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[",]//g\' | tr -d \'[[:space:]]\'', returnStdout: true).trim() |
|||
contractsPackageVersion = sh(script: 'grep "\\"version\\":" ./packages/concordia-contracts/package.json | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[",]//g\' | tr -d \'[[:space:]]\'', returnStdout: true).trim() |
|||
contractsProviderPackageVersion = sh(script: 'grep "\\"version\\":" ./packages/concordia-contracts-provider/package.json | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[",]//g\' | tr -d \'[[:space:]]\'', returnStdout: true).trim() |
|||
pinnerPackageVersion = sh(script: 'grep "\\"version\\":" ./packages/concordia-pinner/package.json | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[",]//g\' | tr -d \'[[:space:]]\'', returnStdout: true).trim() |
|||
sharedPackageVersion = sh(script: 'grep "\\"version\\":" ./packages/concordia-shared/package.json | head -1 | awk -F: \'{ print $2 }\' | sed \'s/[",]//g\' | tr -d \'[[:space:]]\'', returnStdout: true).trim() |
|||
|
|||
echo "Package: app, Version: ${appPackageVersion}, Changed: ${appPackageChanged}" |
|||
echo "Package: contracts, Version: ${contractsPackageVersion}, Changed: ${contractsPackageChanged}" |
|||
echo "Package: contracts-provider, Version: ${contractsProviderPackageVersion}, Changed: ${contractsProviderPackageChanged}" |
|||
echo "Package: pinner, Version: ${pinnerPackageVersion}, Changed: ${pinnerPackageChanged}" |
|||
echo "Package: shared, Version: ${sharedPackageVersion}, Changed: ${sharedPackageChanged}" |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('TEST') { |
|||
parallel { |
|||
stage('TEST CONTRACTS') { |
|||
steps { |
|||
script { |
|||
try { |
|||
def ganacheTestPort = sh(script: "bash ./jenkins/hash_build_properties.sh ${BRANCH_NAME} ${BUILD_NUMBER} | xargs bash ./jenkins/map_to_thousand.sh", returnStdout: true).trim() |
|||
|
|||
def ganacheTestImage = docker.build( |
|||
"ecentrics/concordia-ganache", |
|||
"-f docker/ganache/Dockerfile \ |
|||
./" |
|||
) |
|||
|
|||
sh 'docker network create --driver bridge concordia_ganache_test_network || true' |
|||
|
|||
ganacheTestImage.withRun("""-d -p 6${ganacheTestPort}:8546 \ |
|||
--env-file=./jenkins/env/ganache.test.jenkins.env \ |
|||
--name concordia-ganache-test-6${ganacheTestPort} \ |
|||
--net=concordia_ganache_test_network""") { concordiaGanacheTest -> |
|||
|
|||
contractsTestsImage = docker.build( |
|||
"ecentrics/concordia-contracts-tests:v${contractsPackageVersion}-b${BUILD_NUMBER}-tests", |
|||
"-f docker/concordia-contracts/Dockerfile \ |
|||
./ \ |
|||
--target test \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
|
|||
contractsTestsImage.run("""--rm \ |
|||
-v ecentrics_janus_common:/mnt/concordia/test-reports/ \ |
|||
--env-file=./jenkins/env/contracts.test.jenkins.env \ |
|||
-e WEB3_HOST=concordia-ganache-test-6${ganacheTestPort} \ |
|||
-e WEB3_PORT=6${ganacheTestPort} \ |
|||
--net=concordia_ganache_test_network""") |
|||
|
|||
sh 'mkdir -p ./reports/${BUILD_NUMBER}/contracts' |
|||
sh 'find /mnt/janus/common/ -name "concordia-contracts-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/contracts/ \\;' |
|||
} |
|||
} catch (e) { |
|||
error('Some tests failed!') |
|||
error('Aborting the build.') |
|||
throw e |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('TEST APP') { |
|||
steps { |
|||
script { |
|||
appTestsImage = docker.build( |
|||
"ecentrics/concordia-app:v${appPackageVersion}-b${BUILD_NUMBER}-tests", |
|||
"-f docker/concordia-app/Dockerfile \ |
|||
./ \ |
|||
--target test \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
|
|||
try { |
|||
appTestsImage.run('--rm \ |
|||
-v ecentrics_janus_common:/mnt/concordia/test-reports/') |
|||
|
|||
sh 'mkdir -p ./reports/${BUILD_NUMBER}/app' |
|||
sh 'find /mnt/janus/common/ -name "concordia-app-*" -exec cp \'{}\' ./reports/${BUILD_NUMBER}/app/ \\;' |
|||
} catch (e) { |
|||
error('Some tests failed!') |
|||
error('Aborting the build.') |
|||
throw e |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD FOR PRODUCTION') { |
|||
when { |
|||
branch 'master' |
|||
} |
|||
parallel { |
|||
stage('BUILD CONTRACTS') { |
|||
when { |
|||
expression { |
|||
return "${contractsPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
contractsImage = docker.build( |
|||
"ecentrics/concordia-contracts-migrate:v${contractsPackageVersion}", |
|||
"-f docker/concordia-contracts/Dockerfile \ |
|||
./ \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
|
|||
contractsImage.run('--rm \ |
|||
-v ecentrics_janus_common:/mnt/concordia/build \ |
|||
--entrypoint=sh', |
|||
"-c 'mkdir -p /mnt/concordia/build/contract-artifacts && cp /usr/src/concordia/packages/concordia-contracts/build/* /mnt/concordia/build/contract-artifacts'") |
|||
|
|||
sh 'mkdir -p ./build/${BUILD_NUMBER}/contracts' |
|||
sh 'cp /mnt/janus/common/contract-artifacts/* ./build/${BUILD_NUMBER}/contracts' |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD APP') { |
|||
when { |
|||
expression { |
|||
return "${appPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
appImage = docker.build( |
|||
"ecentrics/concordia-app:v${appPackageVersion}", |
|||
"-f docker/concordia-app/Dockerfile \ |
|||
./ \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD CONTRACTS PROVIDER') { |
|||
when { |
|||
expression { |
|||
return "${contractsProviderPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
contractsProviderImage = docker.build( |
|||
"ecentrics/concordia-contracts-provider:v${contractsProviderPackageVersion}", |
|||
"-f docker/concordia-contracts-provider/Dockerfile \ |
|||
./ \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD PINNER') { |
|||
when { |
|||
expression { |
|||
return "${pinnerPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
pinnerImage = docker.build( |
|||
"ecentrics/concordia-pinner:v${pinnerPackageVersion}", |
|||
"-f docker/concordia-pinner/Dockerfile \ |
|||
./ \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD FOR STAGING') { |
|||
when { |
|||
branch 'develop' |
|||
} |
|||
parallel { |
|||
stage('BUILD CONTRACTS') { |
|||
when { |
|||
expression { |
|||
return "${contractsPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
contractsImage = docker.build( |
|||
"ecentrics/concordia-contracts-migrate:v${contractsPackageVersion}-staging-b${BUILD_NUMBER}", |
|||
"-f docker/concordia-contracts/Dockerfile \ |
|||
./ \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
|
|||
// Get contract artifacts |
|||
contractsImage.run('--rm \ |
|||
-v ecentrics_janus_common:/mnt/concordia/build \ |
|||
--entrypoint=sh', |
|||
"-c 'mkdir -p /mnt/concordia/build/contract-artifacts && cp /usr/src/concordia/packages/concordia-contracts/build/* /mnt/concordia/build/contract-artifacts'") |
|||
|
|||
sh 'mkdir -p ./build/${BUILD_NUMBER}/contracts' |
|||
sh 'cp /mnt/janus/common/contract-artifacts/* ./build/${BUILD_NUMBER}/contracts' |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD APP') { |
|||
when { |
|||
expression { |
|||
return "${appPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
appImage = docker.build( |
|||
"ecentrics/concordia-app:v${appPackageVersion}-staging-b${BUILD_NUMBER}", |
|||
"-f docker/concordia-app/Dockerfile \ |
|||
./ \ |
|||
--target staging \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD CONTRACTS PROVIDER') { |
|||
when { |
|||
expression { |
|||
return "${contractsProviderPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
contractsProviderImage = docker.build( |
|||
"ecentrics/concordia-contracts-provider:v${contractsProviderPackageVersion}-staging-b${BUILD_NUMBER}", |
|||
"-f docker/concordia-contracts-provider/Dockerfile \ |
|||
./ \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('BUILD PINNER') { |
|||
when { |
|||
expression { |
|||
return "${pinnerPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
pinnerImage = docker.build( |
|||
"ecentrics/concordia-pinner:v${pinnerPackageVersion}-staging-b${BUILD_NUMBER}", |
|||
"-f docker/concordia-pinner/Dockerfile \ |
|||
./ \ |
|||
--build-arg TZ=Europe/Athens" |
|||
) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('PUBLISH') { |
|||
when { |
|||
branch 'master' |
|||
} |
|||
parallel { |
|||
stage('PUBLISH CONTRACTS') { |
|||
when { |
|||
expression { |
|||
return "${contractsPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
docker.withRegistry('https://registry.hub.docker.com/', 'docker-hub-concordia') { |
|||
contractsImage.push() |
|||
contractsImage.push('latest') |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('PUBLISH APP') { |
|||
when { |
|||
expression { |
|||
return "${appPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
docker.withRegistry('https://registry.hub.docker.com/', 'docker-hub-concordia') { |
|||
appImage.push() |
|||
appImage.push('latest') |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('PUBLISH CONTRACTS PROVIDER') { |
|||
when { |
|||
expression { |
|||
return "${contractsProviderPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
docker.withRegistry('https://registry.hub.docker.com/', 'docker-hub-concordia') { |
|||
contractsProviderImage.push() |
|||
contractsProviderImage.push('latest') |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('PUBLISH PINNER') { |
|||
when { |
|||
expression { |
|||
return "${pinnerPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
docker.withRegistry('https://registry.hub.docker.com/', 'docker-hub-concordia') { |
|||
pinnerImage.push() |
|||
pinnerImage.push('latest') |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY STAGING') { |
|||
when { |
|||
branch 'develop' |
|||
} |
|||
stages { |
|||
stage('STAGING DEPLOY PREPARATION') { |
|||
steps { |
|||
script { |
|||
sh 'docker network create --driver bridge ecentrics_concordia_staging_network || true' |
|||
|
|||
def rendezvousServerRunning = sh (script: 'docker ps -f name=concordia-rendezvous | \ |
|||
grep -qE concordia-rendezvous', returnStatus: true) |
|||
|
|||
if ("$rendezvousServerRunning" == '1') { |
|||
sh 'docker run \ |
|||
-d \ |
|||
-p 9090:9090 \ |
|||
--name concordia-rendezvous \ |
|||
--net=ecentrics_concordia_staging_network \ |
|||
libp2p/js-libp2p-webrtc-star:version-0.20.5' |
|||
} else { |
|||
sh 'docker network connect ecentrics_concordia_staging_network concordia-rendezvous || true' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY CONTRACTS PROVIDER') { |
|||
when { |
|||
expression { |
|||
def contractsProviderStagingRunning = sh (script: 'docker ps -f name=concordia-contracts-provider-staging | \ |
|||
grep -qE concordia-contracts-provider-staging', returnStatus: true) |
|||
return "${contractsProviderPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' || "$contractsProviderStagingRunning" == '1' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-contracts-provider-staging || true \ |
|||
&& docker rm concordia-contracts-provider-staging || true' |
|||
|
|||
sh 'if [ "$cleanSlateEnabled" -eq "0" ]; then \ |
|||
docker volume rm concordia-contracts-provider-staging || true; \ |
|||
fi' |
|||
|
|||
sh (script: """docker run \ |
|||
-d \ |
|||
-v concordia-contracts-provider-staging:/mnt/concordia/contracts \ |
|||
--env-file=./jenkins/env/contracts.provider.staging.env \ |
|||
-p 8450:8450 \ |
|||
--name concordia-contracts-provider-staging \ |
|||
--net=ecentrics_concordia_staging_network \ |
|||
ecentrics/concordia-contracts-provider:v${contractsProviderPackageVersion}-staging-b${BUILD_NUMBER}""") |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('RECREATE GANACHE') { |
|||
when { |
|||
expression { |
|||
def ganacheStagingRunning = sh (script: 'docker ps -f name=concordia-ganache-staging | \ |
|||
grep -qE concordia-ganache-staging', returnStatus: true) |
|||
return "$cleanSlateEnabled" == '0' || "$ganacheStagingRunning" == '1'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-ganache-staging || true \ |
|||
&& docker rm concordia-ganache-staging || true' |
|||
|
|||
sh 'docker volume rm concordia-ganache-staging || true' |
|||
|
|||
sh (script: 'docker run \ |
|||
-d \ |
|||
-v concordia-ganache-staging:/mnt/concordia/ganache_keys \ |
|||
-p 8555:8555 \ |
|||
--env-file=./jenkins/env/ganache.staging.jenkins.env \ |
|||
--name concordia-ganache-staging \ |
|||
--net=ecentrics_concordia_staging_network \ |
|||
ecentrics/concordia-ganache:latest') |
|||
|
|||
// Ganache image might take a while to come alive |
|||
sleep 10 |
|||
|
|||
sh 'mkdir -p ./ganache/ && docker cp concordia-ganache-staging:/mnt/concordia/ganache_keys/keys.json ./ganache/' |
|||
freshGanacheStagingRunning = true |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY CONTRACTS') { |
|||
when { |
|||
expression { |
|||
return "${contractsPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' || "$freshGanacheStagingRunning" || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh """docker run \ |
|||
--rm \ |
|||
--env-file=./jenkins/env/contracts.staging.jenkins.env \ |
|||
-e CONTRACTS_VERSION_HASH=${contractsPackageVersion}-dev \ |
|||
--net=ecentrics_concordia_staging_network \ |
|||
ecentrics/concordia-contracts-migrate:v${contractsPackageVersion}-staging-b${BUILD_NUMBER}""" |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY PINNER') { |
|||
when { |
|||
expression { |
|||
def pinnerStagingRunning = sh (script: 'docker ps -f name=concordia-pinner-staging | \ |
|||
grep -qE concordia-pinner-staging', returnStatus: true) |
|||
return "${pinnerPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' || "${contractsPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-pinner-staging || true \ |
|||
&& docker rm concordia-pinner-staging || true' |
|||
|
|||
sh 'if [ "$cleanSlateEnabled" -eq "0" ]; then \ |
|||
docker volume rm concordia-pinner-staging || true; \ |
|||
fi' |
|||
|
|||
sh """docker run \ |
|||
-d \ |
|||
-v concordia-pinner-staging:/mnt/concordia/orbitdb \ |
|||
-p 5555:5555 \ |
|||
--env-file=./jenkins/env/pinner.staging.jenkins.env \ |
|||
--name concordia-pinner-staging \ |
|||
--net=ecentrics_concordia_staging_network \ |
|||
ecentrics/concordia-pinner:v${pinnerPackageVersion}-staging-b${BUILD_NUMBER}""" |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY APP') { |
|||
when { |
|||
expression { |
|||
def pinnerStagingRunning = sh (script: 'docker ps -f name=concordia-app-staging | \ |
|||
grep -qE concordia-app-staging', returnStatus: true) |
|||
return "${appPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
|
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-app-staging || true \ |
|||
&& docker rm concordia-app-staging || true' |
|||
|
|||
sh """docker run \ |
|||
-itd \ |
|||
-p 7000:3000 \ |
|||
--env-file=./jenkins/env/concordia.staging.jenkins.env \ |
|||
--name concordia-app-staging \ |
|||
ecentrics/concordia-app:v${appPackageVersion}-staging-b${BUILD_NUMBER}""" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY PRODUCTION') { |
|||
when { |
|||
branch 'master' |
|||
} |
|||
stages { |
|||
stage('PRODUCTION DEPLOY PREPARATION') { |
|||
steps { |
|||
script { |
|||
sh 'docker network create --driver bridge ecentrics_concordia_production_network || true' |
|||
|
|||
def rendezvousServerRunning = sh (script: 'docker ps -f name=concordia-rendezvous | \ |
|||
grep -qE concordia-rendezvous', returnStatus: true) |
|||
|
|||
if ("$rendezvousServerRunning" == '1') { |
|||
sh 'docker run \ |
|||
-d \ |
|||
-p 9090:9090 \ |
|||
--name concordia-rendezvous \ |
|||
--net=ecentrics_concordia_production_network \ |
|||
libp2p/js-libp2p-webrtc-star:version-0.20.5' |
|||
} else { |
|||
sh 'docker network connect ecentrics_concordia_production_network concordia-rendezvous || true' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY CONTRACTS PROVIDER') { |
|||
when { |
|||
expression { |
|||
def contractsProviderProductionRunning = sh (script: 'docker ps -f name=concordia-contracts-provider-production | \ |
|||
grep -qE concordia-contracts-provider-production', returnStatus: true) |
|||
return "${contractsProviderPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' || "$contractsProviderProductionRunning" == '1' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-contracts-provider-production || true \ |
|||
&& docker rm concordia-contracts-provider-production || true' |
|||
|
|||
sh 'if [ "$cleanSlateEnabled" -eq "0" ]; then \ |
|||
docker volume rm concordia-contracts-provider-production || true; \ |
|||
fi' |
|||
|
|||
sh (script: """docker run \ |
|||
-d \ |
|||
-v concordia-contracts-provider-production:/mnt/concordia/contracts \ |
|||
--env-file=./jenkins/env/contracts.provider.production.env \ |
|||
-e NODE_ENV=production \ |
|||
-p 8400:8400 \ |
|||
--name concordia-contracts-provider-production \ |
|||
--net=ecentrics_concordia_production_network \ |
|||
ecentrics/concordia-contracts-provider:v${contractsProviderPackageVersion}""") |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('RECREATE GANACHE') { |
|||
when { |
|||
expression { |
|||
def ganacheProductionRunning = sh (script: 'docker ps -f name=concordia-ganache-production | \ |
|||
grep -qE concordia-ganache-production', returnStatus: true) |
|||
return "$cleanSlateEnabled" == '0' || "$ganacheProductionRunning" == '1'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-ganache-production || true \ |
|||
&& docker rm concordia-ganache-production || true' |
|||
|
|||
sh 'docker volume rm concordia-ganache-production || true' |
|||
|
|||
sh (script: 'docker run \ |
|||
-d \ |
|||
-v concordia-ganache-production:/mnt/concordia/ganache_keys \ |
|||
-p 8545:8545 \ |
|||
--env-file=./jenkins/env/ganache.production.jenkins.env \ |
|||
--name concordia-ganache-production \ |
|||
--net=ecentrics_concordia_production_network \ |
|||
ecentrics/concordia-ganache:latest') |
|||
|
|||
// Ganache image might take a while to come alive |
|||
sleep 10 |
|||
|
|||
sh 'mkdir -p ./ganache/ && docker cp concordia-ganache-production:/mnt/concordia/ganache_keys/keys.json ./ganache/' |
|||
freshGanacheProductionRunning = true |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY CONTRACTS') { |
|||
when { |
|||
expression { |
|||
return "${contractsPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' || "$freshGanacheProductionRunning" || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh """docker run \ |
|||
--rm \ |
|||
--env-file=./jenkins/env/contracts.production.jenkins.env \ |
|||
-e CONTRACTS_VERSION_HASH=${contractsPackageVersion} \ |
|||
--net=ecentrics_concordia_production_network \ |
|||
ecentrics/concordia-contracts-migrate:v${contractsPackageVersion}""" |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY PINNER') { |
|||
when { |
|||
expression { |
|||
def pinnerProductionRunning = sh (script: 'docker ps -f name=concordia-pinner-production | \ |
|||
grep -qE concordia-pinner-production', returnStatus: true) |
|||
return "${pinnerPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' || "${pinnerProductionRunning}" == '1' || "${contractsPackageChanged}" == '0' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-pinner-production || true \ |
|||
&& docker rm concordia-pinner-production || true' |
|||
|
|||
sh 'if [ "$cleanSlateEnabled" -eq "0" ]; then \ |
|||
docker volume rm concordia-pinner-production || true; \ |
|||
fi' |
|||
|
|||
sh """docker run \ |
|||
-d \ |
|||
-v concordia-pinner-production:/mnt/concordia/orbitdb \ |
|||
-p 4444:4444 \ |
|||
-e NODE_ENV=production \ |
|||
--env-file=./jenkins/env/pinner.production.jenkins.env \ |
|||
--name concordia-pinner-production \ |
|||
--net=ecentrics_concordia_production_network \ |
|||
ecentrics/concordia-pinner:v${pinnerPackageVersion}""" |
|||
} |
|||
} |
|||
} |
|||
|
|||
stage('DEPLOY APP') { |
|||
when { |
|||
expression { |
|||
def appProductionRunning = sh (script: 'docker ps -f name=concordia-app-production | \ |
|||
grep -qE concordia-app-production', returnStatus: true) |
|||
return "${appPackageChanged}" == '0' || "$cleanSlateEnabled" == '0' ||"${appProductionRunning}" == '1' || "${sharedPackageChanged}" == '0'; |
|||
} |
|||
} |
|||
|
|||
steps { |
|||
script { |
|||
sh 'docker stop concordia-app-production || true \ |
|||
&& docker rm concordia-app-production || true' |
|||
|
|||
sh """docker run \ |
|||
-d \ |
|||
-p 7777:80 \ |
|||
--env-file=./jenkins/env/concordia.production.jenkins.env \ |
|||
--name concordia-app-production \ |
|||
ecentrics/concordia-app:v${appPackageVersion}""" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,24 @@ |
|||
#!/bin/bash |
|||
|
|||
# Based on this post: |
|||
# https://engineering.brigad.co/only-deploy-services-impacted-by-changes-in-a-mono-repository-18f54b8ac109 |
|||
|
|||
APP=$1 |
|||
# Jenkins should provide these in the environment by default |
|||
GIT_COMMIT=$2 |
|||
GIT_PREVIOUS_COMMIT=$3 |
|||
ROOT_FILES_AND_FOLDERS=${4:-"package.json" "yarn.lock" ".dockerignore" "docker" "jenkins"} |
|||
|
|||
function join_by { local IFS="$1"; shift; echo "$*"; } |
|||
|
|||
function package_changed { git diff --name-only "$COMMIT_RANGE" | grep -qE "^packages/$1/" && echo true || echo false; } |
|||
|
|||
COMMIT_RANGE="$GIT_PREVIOUS_COMMIT...$GIT_COMMIT" |
|||
ROOT_FILES_AND_FOLDERS_ARRAY=($ROOT_FILES_AND_FOLDERS) |
|||
ROOT_FILES_AND_FOLDERS_JOINED=$(join_by "|" ${ROOT_FILES_AND_FOLDERS_ARRAY[*]}) |
|||
|
|||
ROOT_FILES_CHANGED=$(git diff --name-only "$COMMIT_RANGE" | grep -qE "^($ROOT_FILES_AND_FOLDERS_JOINED)" && echo true || echo false) |
|||
IS_FORCE_BUILD=$(git log --oneline "$COMMIT_RANGE" | grep -qE "ci: force" && echo true || echo false) |
|||
APP_FILES_CHANGED=$(package_changed ${APP}) |
|||
|
|||
($IS_FORCE_BUILD || $ROOT_FILES_CHANGED || $APP_FILES_CHANGED) && echo 0 || echo 1 |
@ -0,0 +1,16 @@ |
|||
VIRTUAL_HOST=concordia.ecentrics.net |
|||
VIRTUAL_PORT=7777 |
|||
LETSENCRYPT_HOST=concordia.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
# Variables needed in runtime (in browser) |
|||
REACT_APP_CONCORDIA_HOST=concordia.ecentrics.net |
|||
REACT_APP_CONCORDIA_PORT=7777 |
|||
|
|||
REACT_APP_RENDEZVOUS_HOST=rendezvous.ecentrics.net |
|||
REACT_APP_RENDEZVOUS_PORT=9090 |
|||
|
|||
REACT_APP_USE_EXTERNAL_CONTRACTS_PROVIDER=true |
|||
REACT_APP_CONTRACTS_PROVIDER_HOST=contracts.concordia.ecentrics.net |
|||
REACT_APP_CONTRACTS_PROVIDER_PORT=8400 |
|||
REACT_APP_CONTRACTS_VERSION_HASH=stable |
@ -0,0 +1,16 @@ |
|||
VIRTUAL_HOST=staging.concordia.ecentrics.net |
|||
VIRTUAL_PORT=7000 |
|||
LETSENCRYPT_HOST=staging.concordia.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
# Variables needed in runtime (in browser) |
|||
REACT_APP_CONCORDIA_HOST=staging.concordia.ecentrics.net |
|||
REACT_APP_CONCORDIA_PORT=7000 |
|||
|
|||
REACT_APP_RENDEZVOUS_HOST=rendezvous.ecentrics.net |
|||
REACT_APP_RENDEZVOUS_PORT=9090 |
|||
|
|||
REACT_APP_USE_EXTERNAL_CONTRACTS_PROVIDER=true |
|||
REACT_APP_CONTRACTS_PROVIDER_HOST=staging.contracts.concordia.ecentrics.net |
|||
REACT_APP_CONTRACTS_PROVIDER_PORT=8450 |
|||
REACT_APP_CONTRACTS_VERSION_HASH=latest |
@ -0,0 +1,8 @@ |
|||
# Variables needed in runtime |
|||
MIGRATE_NETWORK=env |
|||
WEB3_HOST=concordia-ganache-production |
|||
WEB3_PORT=8545 |
|||
|
|||
CONTRACTS_PROVIDER_HOST=contracts.concordia.ecentrics.net |
|||
CONTRACTS_PROVIDER_PORT=8400 |
|||
CONTRACTS_VERSION_TAG=stable |
@ -0,0 +1,8 @@ |
|||
VIRTUAL_HOST=contracts.concordia.ecentrics.net |
|||
VIRTUAL_PORT=8400 |
|||
LETSENCRYPT_HOST=contracts.concordia.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
CONTRACTS_PROVIDER_PORT=8400 |
|||
UPLOAD_CONTRACTS_DIRECTORY=/mnt/concordia/contracts/ |
|||
CORS_ALLOWED_ORIGINS="concordia.ecentrics.net;http://concordia.ecentrics.net;https://concordia.ecentrics.net;concordia.ecentrics.net:7777;http://concordia.ecentrics.net:7777;https://concordia.ecentrics.net:7777;127.0.0.1;http://127.0.0.1;127.0.0.1:7777;http://127.0.0.1" |
@ -0,0 +1,8 @@ |
|||
VIRTUAL_HOST=staging.contracts.concordia.ecentrics.net |
|||
VIRTUAL_PORT=8450 |
|||
LETSENCRYPT_HOST=staging.contracts.concordia.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
CONTRACTS_PROVIDER_PORT=8450 |
|||
UPLOAD_CONTRACTS_DIRECTORY=/mnt/concordia/contracts/ |
|||
#CORS_ALLOWED_ORIGINS="staging.concordia.ecentrics.net;http://staging.concordia.ecentrics.net;https://staging.concordia.ecentrics.net;staging.concordia.ecentrics.net:7000;http://staging.concordia.ecentrics.net:7000;https://staging.concordia.ecentrics.net:7000;172.21.0.4;http://172.21.0.4;127.0.0.1;http://127.0.0.1" |
@ -0,0 +1,8 @@ |
|||
# Variables needed in runtime |
|||
MIGRATE_NETWORK=env |
|||
WEB3_HOST=concordia-ganache-staging |
|||
WEB3_PORT=8555 |
|||
|
|||
CONTRACTS_PROVIDER_HOST=staging.contracts.concordia.ecentrics.net |
|||
CONTRACTS_PROVIDER_PORT=8450 |
|||
CONTRACTS_VERSION_TAG=latest |
@ -0,0 +1,4 @@ |
|||
# Variables needed in runtime |
|||
MIGRATE_NETWORK=env |
|||
WEB3_HOST=concordia-ganache-test |
|||
WEB3_PORT=8546 |
@ -0,0 +1,10 @@ |
|||
VIRTUAL_HOST=ganache.ecentrics.net |
|||
VIRTUAL_PORT=8545 |
|||
LETSENCRYPT_HOST=ganache.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
ACCOUNTS_NUMBER=1000 |
|||
ACCOUNTS_ETHER=100000 |
|||
HOST=0.0.0.0 |
|||
PORT=8545 |
|||
NETWORK_ID=5778 |
@ -0,0 +1,10 @@ |
|||
VIRTUAL_HOST=staging.ganache.ecentrics.net |
|||
VIRTUAL_PORT=8555 |
|||
LETSENCRYPT_HOST=staging.ganache.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
ACCOUNTS_NUMBER=100 |
|||
ACCOUNTS_ETHER=1000 |
|||
HOST=0.0.0.0 |
|||
PORT=8555 |
|||
NETWORK_ID=5778 |
@ -0,0 +1,6 @@ |
|||
ACCOUNTS_NUMBER=5 |
|||
ACCOUNTS_ETHER=1 |
|||
MNEMONIC="myth like bonus scare over problem client lizard pioneer submit female collect" |
|||
HOST=0.0.0.0 |
|||
PORT=8546 |
|||
NETWORK_ID=5778 |
@ -0,0 +1,20 @@ |
|||
VIRTUAL_HOST=pinner.concordia.ecentrics.net |
|||
VIRTUAL_PORT=4444 |
|||
LETSENCRYPT_HOST=pinner.concordia.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
USE_EXTERNAL_CONTRACTS_PROVIDER=true |
|||
ORBIT_DIRECTORY=/mnt/concordia/orbitdb |
|||
|
|||
CONTRACTS_PROVIDER_HOST=contracts.concordia.ecentrics.net |
|||
CONTRACTS_PROVIDER_PORT=8400 |
|||
CONTRACTS_VERSION_HASH=stable |
|||
|
|||
PINNER_API_HOST=127.0.0.1 |
|||
PINNER_API_PORT=4444 |
|||
|
|||
RENDEZVOUS_HOST=rendezvous.ecentrics.net |
|||
RENDEZVOUS_PORT=9090 |
|||
|
|||
WEB3_HOST=ganache.ecentrics.net |
|||
WEB3_PORT=8545 |
@ -0,0 +1,20 @@ |
|||
VIRTUAL_HOST=staging.pinner.concordia.ecentrics.net |
|||
VIRTUAL_PORT=5555 |
|||
LETSENCRYPT_HOST=staging.pinner.concordia.ecentrics.net |
|||
LETSENCRYPT_EMAIL=ecentricsgr@gmail.com |
|||
|
|||
USE_EXTERNAL_CONTRACTS_PROVIDER=true |
|||
ORBIT_DIRECTORY=/mnt/concordia/orbitdb |
|||
|
|||
CONTRACTS_PROVIDER_HOST=staging.contracts.concordia.ecentrics.net |
|||
CONTRACTS_PROVIDER_PORT=8450 |
|||
CONTRACTS_VERSION_HASH=latest |
|||
|
|||
PINNER_API_HOST=127.0.0.1 |
|||
PINNER_API_PORT=5555 |
|||
|
|||
RENDEZVOUS_HOST=rendezvous.ecentrics.net |
|||
RENDEZVOUS_PORT=9090 |
|||
|
|||
WEB3_HOST=staging.ganache.ecentrics.net |
|||
WEB3_PORT=8555 |
@ -0,0 +1,18 @@ |
|||
#!/bin/bash |
|||
|
|||
# Outputs to the stdout a deterministically generated integer in the range 0-4095. The integer is generated using the |
|||
# input strings and SHA1. |
|||
# Usage: hash_build_properties.sh <branch> <build_number> |
|||
# Inputs: |
|||
# - branch: the branch being build |
|||
# - build_number the incrementing number of the build |
|||
|
|||
BRANCH=$1 |
|||
BUILD_NUMBER=$2 |
|||
|
|||
STRING_TO_HASH="$BRANCH-$BUILD_NUMBER" |
|||
SHA1_SUM_HEX=$(sha1sum <<<"$STRING_TO_HASH") |
|||
SHA1_TRUNCATED_HEX=$(cut -c1-3 <<<"$SHA1_SUM_HEX") |
|||
HASHED_STRING=$((0x${SHA1_TRUNCATED_HEX})) |
|||
|
|||
echo "$HASHED_STRING" |
@ -0,0 +1,5 @@ |
|||
#!/bin/bash |
|||
|
|||
INTEGER_TO_MAP=$1 |
|||
|
|||
echo $(( INTEGER_TO_MAP * 999 / 4095 )) |
@ -1,31 +1,38 @@ |
|||
import * as fs from 'fs'; |
|||
import { promises as fs, constants } from 'fs'; |
|||
import path from 'path'; |
|||
import { getStorageLocation, getTagsDirectory } from '../utils/storageUtils'; |
|||
|
|||
const readContractFilesToArray = (contractsDirectoryPath) => fs |
|||
.readdir(contractsDirectoryPath) |
|||
.then((contractFilenames) => contractFilenames |
|||
.map((contractFilename) => fs |
|||
.readFile(path.join(`${contractsDirectoryPath}/${contractFilename}`), 'utf-8') |
|||
.then((rawContractData) => JSON.parse(rawContractData)))) |
|||
.then((contractObjectPromises) => Promise.all([...contractObjectPromises])); |
|||
|
|||
const downloadContracts = async (req, res) => { |
|||
const { params: { hash: hashOrTag } } = req; |
|||
let directoryPath = getStorageLocation(hashOrTag); |
|||
const { params: { hash: identifier } } = req; |
|||
const hashBasedDirectoryPath = getStorageLocation(identifier); |
|||
|
|||
if (!fs.existsSync(directoryPath)) { |
|||
return fs.access(hashBasedDirectoryPath, constants.R_OK) |
|||
.then(() => readContractFilesToArray(hashBasedDirectoryPath)) |
|||
.catch(() => { |
|||
const tagsDirectory = getTagsDirectory(); |
|||
|
|||
if (fs.existsSync(tagsDirectory)) { |
|||
const tagFilePath = path.join(tagsDirectory, hashOrTag); |
|||
const tagReference = fs.readFileSync(tagFilePath, 'utf-8'); |
|||
|
|||
directoryPath = getStorageLocation(tagReference); |
|||
} |
|||
} |
|||
return fs |
|||
.access(tagsDirectory, constants.R_OK) |
|||
.then(() => { |
|||
const tagFilePath = path.join(tagsDirectory, identifier); |
|||
|
|||
const contracts = []; |
|||
return fs.readFile(tagFilePath, 'utf-8') |
|||
.then((tagReference) => { |
|||
const tagBasedDirectoryPath = getStorageLocation(tagReference); |
|||
|
|||
fs.readdirSync(directoryPath).forEach((contractFilename) => { |
|||
const rawContractData = fs.readFileSync(path.join(`${directoryPath}/${contractFilename}`), 'utf-8'); |
|||
const contractJson = JSON.parse(rawContractData); |
|||
contracts.push(contractJson); |
|||
return readContractFilesToArray(tagBasedDirectoryPath); |
|||
}); |
|||
|
|||
res.send(contracts); |
|||
}); |
|||
}).then((contracts) => res.send(contracts)) |
|||
.catch(() => Promise.reject(new Error(`No contracts version or tag found for ${identifier}.`))); |
|||
}; |
|||
|
|||
export default downloadContracts; |
|||
|
@ -1,37 +1,44 @@ |
|||
import path from 'path'; |
|||
import fs from 'fs'; |
|||
import upload from '../middleware/upload'; |
|||
import { getTagsDirectory } from '../utils/storageUtils'; |
|||
import { constants, promises as fs } from 'fs'; |
|||
import uploadFilesUsingMiddleware from '../middleware/upload'; |
|||
import { getStorageLocation, getTagsDirectory } from '../utils/storageUtils'; |
|||
|
|||
const provisionContractsDirectory = (req) => { |
|||
const { params: { hash } } = req; |
|||
const contractsPath = getStorageLocation(hash); |
|||
|
|||
return fs |
|||
.access(contractsPath, constants.W_OK) |
|||
.then(() => fs.rmdir(contractsPath, { recursive: true })) |
|||
.catch(() => Promise.resolve()) |
|||
.then(() => fs.mkdir(contractsPath, { recursive: true })); |
|||
}; |
|||
|
|||
const addOrTransferTag = (tag, hash) => { |
|||
const tagsDirectory = getTagsDirectory(); |
|||
const tagFilePath = path.join(tagsDirectory, tag); |
|||
|
|||
fs.mkdirSync(tagsDirectory, { recursive: true }); |
|||
fs.writeFileSync(tagFilePath, hash); |
|||
return fs |
|||
.mkdir(tagsDirectory, { recursive: true }) |
|||
.then(() => fs.writeFile(tagFilePath, hash, 'utf-8')); |
|||
}; |
|||
|
|||
const uploadContracts = async (req, res) => { |
|||
try { |
|||
await upload(req, res); |
|||
const uploadContracts = async (req, res) => provisionContractsDirectory(req) |
|||
.then(() => uploadFilesUsingMiddleware(req, res) |
|||
.then(() => { |
|||
if (req.files.length <= 0) { |
|||
return Promise.reject(new Error('You must select at least 1 file.')); |
|||
} |
|||
|
|||
const { body: { tag } } = req; |
|||
const { params: { hash } } = req; |
|||
|
|||
if (tag) { |
|||
addOrTransferTag(tag, hash); |
|||
} |
|||
|
|||
if (req.files.length <= 0) { |
|||
return res.send('You must select at least 1 file.'); |
|||
return addOrTransferTag(tag, hash) |
|||
.then(() => res.send('Files have been uploaded and tagged.')); |
|||
} |
|||
|
|||
return res.send('Files have been uploaded.'); |
|||
} catch (error) { |
|||
console.log(error); |
|||
|
|||
return res.send(`Error when trying upload many files: ${error}`); |
|||
} |
|||
}; |
|||
})); |
|||
|
|||
export default uploadContracts; |
|||
|
@ -0,0 +1,11 @@ |
|||
pragma solidity >=0.4.21 <0.7.0; |
|||
|
|||
import "truffle/Assert.sol"; |
|||
import "../contracts/Forum.sol"; |
|||
|
|||
contract TestForum { |
|||
function testTrue() public { |
|||
|
|||
Assert.isTrue(true, "Oops placeholder test failed!"); |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
const Forum = artifacts.require('Forum'); |
|||
|
|||
contract('Forum', (accounts) => { |
|||
it('...should succeed.', async () => { |
|||
const forumInstance = await Forum.deployed(); |
|||
|
|||
assert |
|||
.ok(forumInstance |
|||
.signUp('testUsername', { from: accounts[0] }), 'The user was not created.'); |
|||
}); |
|||
}); |
@ -1,6 +1,5 @@ |
|||
import path from 'path'; |
|||
import getBreezeConfiguration from 'concordia-shared/src/configuration/breezeConfiguration'; |
|||
|
|||
export const swarmAddresses = getBreezeConfiguration().ipfs.config.Addresses.Swarm; |
|||
const ORBIT_DIRECTORY_DEFAULT = path.join(__dirname, '..', 'orbitdb'); |
|||
|
|||
export const ORBIT_DIRECTORY_DEFAULT = path.join(__dirname, '..', 'orbitdb'); |
|||
export default ORBIT_DIRECTORY_DEFAULT; |
|||
|
@ -0,0 +1,11 @@ |
|||
import dns from 'dns'; |
|||
import util from 'util'; |
|||
import { rendezvousHost, rendezvousPort } from 'concordia-shared/src/environment/interpolated/rendezvous'; |
|||
|
|||
const dnsLookup = util.promisify(dns.lookup); |
|||
|
|||
export const getResolvedRendezvousUrl = async () => dnsLookup(rendezvousHost, { family: 4 }) |
|||
.catch((error) => console.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`))); |
|||
|
|||
export const getSwarmAddresses = async () => getResolvedRendezvousUrl() |
|||
.then((resolvedRendezvousUrl) => [`/ip4/${resolvedRendezvousUrl.address}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`]); |
Loading…
Reference in new issue