Skip to content

Commit

Permalink
Add support for providing custom ui config to Docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
svienot committed Aug 30, 2023
1 parent df73bf9 commit 06895ec
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ server.log
ui/node_modules/
ui/dist/
ui/.cache/
ui/docker-config.json
source-verify.dab
dist/
**/.env
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,20 @@ or build the images locally.

### Build steps

1. Run `docker-compose -f environments/build-ui.yaml build`.
2. Run `docker-compose -f environments/build-server.yaml build`.
3. Run `docker-compose -f environments/build-repository.yaml build`.
1. Run `docker-compose -f environments/build-ui.yaml build`
2. Run `docker-compose -f environments/build-server.yaml build`
3. Run `docker-compose -f environments/build-repository.yaml build`

### Run

1. `cp environments/.env.docker.hedera environments/.env`
2. Adjust the configuration as follows:
* Replace all occurences of `localhost` by the fully qualified hostname if not running locally
2. Adjust the configuration in `environments/.env` as follows:
* Replace all occurrences of `localhost` by the fully qualified hostname if not running locally
* Use port 5555 instead of 5000 if running on a Mac
3. Run `docker-compose -f environments/docker-compose-hedera.yaml up -d repository server ui`
4. `Open http://localhost:1234` to bring up the Verifier page.
3. `cp ui/example-docker-config.json ui/docker-config.json`
4. Adjust the URLs in `docker-config.json` as needed
5. Run `docker-compose -f environments/docker-compose-hedera.yaml up -d repository server ui`
6. `Open http://localhost:1234` to bring up the Verifier page.

### Stop

Expand Down
4 changes: 4 additions & 0 deletions environments/docker-compose-hedera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ services:
interval: 30s
timeout: 10s
retries: 10
volumes:
- type: bind
source: ../ui/docker-config.json
target: /usr/share/nginx/html/config.json
ports:
- "${UI_EXTERNAL_PORT}:80"

Expand Down
4 changes: 4 additions & 0 deletions environments/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ services:
interval: 30s
timeout: 10s
retries: 10
volumes:
- type: bind
source: ../ui/docker-config.json
target: /usr/share/nginx/html/config.json
ports:
- "${UI_EXTERNAL_PORT}:80"
12 changes: 8 additions & 4 deletions test/test-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('Basic non-regression of hedera-sourcify server', function () {

it('Should return correct verification status for newly created contract', async function () {

let health = await axios.get(`${SERVER_URL}/health`)
console.log(`health: ${JSON.stringify(health.data)}`)

// Grab Hedera network, account ID and private key from .env file
const network = process.env.HEDERA_NETWORK ?? 'local'
const accountId = process.env.OPERATOR_ACCOUNT_ID
Expand All @@ -36,15 +39,16 @@ describe('Basic non-regression of hedera-sourcify server', function () {
"HelloHedera.sol"
);
const contractAddress = contractId.toSolidityAddress()
// console.log("Deployed contract Address is " + contractAddress);
console.log("Deployed contract Address is " + contractAddress);

// Make call to Sourcify to check that contract is not verified
const checkUrl = `${SERVER_URL}/check-by-addresses?addresses=${contractAddress}&chainIds=${chainId}`

let response = await axios.get(checkUrl)
// console.log(`verification status for contract ${response.data[0].address} is: ${response.data[0].status}`);
console.log(`verification status for contract ${response.data[0].address} is: ${response.data[0].status}`);
expect(response.data[0].status).to.equal('false');


// Make call to Sourcify to submit contract verification
const solidityFileContent = fs.readFileSync("./test/hello-hedera/HelloHedera.sol");
const metadataFileContent = fs.readFileSync("./test/hello-hedera/HelloHedera_metadata.json");
Expand All @@ -59,12 +63,12 @@ describe('Basic non-regression of hedera-sourcify server', function () {
}

response = await axios.post(`${SERVER_URL}/verify`, verificationData)
// console.log(`verification response: ${JSON.stringify(response.data)}`);
console.log(`verification response: ${JSON.stringify(response.data)}`);
expect(response.data.result[0].status).to.equal('perfect');

// Make call to Sourcify to check that contract is now verified
response = await axios.get(checkUrl)
// console.log(`verification status for contract ${response.data[0].address} is: ${response.data[0].status}`);
console.log(`verification status for contract ${response.data[0].address} is: ${response.data[0].status}`);
expect(response.data[0].status).to.equal('perfect');

return Promise.resolve();
Expand Down
3 changes: 0 additions & 3 deletions ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
FROM node:16-alpine AS builder

# To be injected by create-react-app on build time
ARG SERVER_URL
ARG REPOSITORY_SERVER_URL
ARG IPNS
ARG TAG

RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
Expand Down
5 changes: 5 additions & 0 deletions ui/example-docker-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"SERVER_URL": "http://localhost:5556",
"REPOSITORY_SERVER_URL": "http://localhost:10000",
"HASHSCAN_URL": "https://hashscan-latest.hedera-devops.com"
}

0 comments on commit 06895ec

Please sign in to comment.