Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use upstream Sourcify images #164

Merged
merged 72 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3639575
Remove unused `ARG TAG` from `ui`
acuarica Apr 22, 2024
bc87cbf
Clean up unused `ui` build args in CI
acuarica Apr 22, 2024
291a363
Remove references to old env vars
acuarica Apr 22, 2024
2d4c87f
Move `ui` build into main hedera compose config
acuarica Apr 22, 2024
0d9b6de
Use upstream Sourcify image locally
acuarica Apr 24, 2024
c54b7a8
Use better default for `SERVER_URL` in `ui`
acuarica Apr 25, 2024
71364af
Ignore files locally
acuarica Apr 25, 2024
4c2787b
Add `data` placeholder folder to place repository contracts
acuarica Apr 25, 2024
b0064e7
Clean up doc
acuarica Apr 25, 2024
45d0852
Apply new configuration for upstream Sourcify images
acuarica Apr 25, 2024
441d632
Remove server to use upstream Sourcify
acuarica May 8, 2024
2e95cd5
Remove server config files
acuarica May 8, 2024
d7bd990
Move tools to root
acuarica May 8, 2024
0a8f96d
Add upstream Sourcify to build and run `server` image
acuarica May 9, 2024
0120af8
Update repo service to include bug fixes
acuarica May 9, 2024
4766c68
Move setup to root
acuarica May 9, 2024
d71fa14
Remove lerna setup
acuarica May 9, 2024
16c4ec6
Use code fences for `npm` commands
acuarica May 9, 2024
1a0529f
Clean up git ignores
acuarica May 9, 2024
74dad9a
Remove packages unit tests in CI
acuarica May 10, 2024
1de0270
Simplify compose
acuarica May 10, 2024
1efd731
Remove unused `dirty` flag
acuarica May 11, 2024
92b92a9
Set up repository build to hide open in Remix link
acuarica May 11, 2024
0095d70
Remove envs
acuarica May 13, 2024
fafb014
Clean up unused tests
acuarica May 14, 2024
c4e2315
Build new images in integration environment
acuarica May 14, 2024
c8c4541
Fix integration workflow
acuarica May 14, 2024
7819571
Restore old image name schema
acuarica May 14, 2024
d3cba77
Publish each package separately
acuarica May 14, 2024
8276d4a
Restore smoke tests
acuarica May 14, 2024
4eadf1e
Regenerate lock file
acuarica May 14, 2024
ecc8d27
Checkout with submodules to compile in sourcify
acuarica May 14, 2024
979cf6f
Use developement to start sourcify server
acuarica May 14, 2024
8fb7d90
Set up chains for smoke tests
acuarica May 14, 2024
879599e
Add env for compose and draft docs
acuarica May 14, 2024
757d779
Remove any dangling reference to script, deps and tests
acuarica May 15, 2024
104abbf
Remove unused ipfs dep as well
acuarica May 15, 2024
3809a5d
Remove unsupported ganache dep
acuarica May 15, 2024
0a12a59
Increase gas to deploy contract with new local node/SDK version
acuarica May 15, 2024
d95a70f
Update Test section
acuarica May 15, 2024
05a8cc3
Use verbose args in scripts
acuarica May 15, 2024
a42cc09
Restore network reset script
acuarica May 15, 2024
8d2ca49
Include server default config
acuarica May 15, 2024
ff12d96
Update subrepo to include toggle open in remix link
acuarica May 16, 2024
3d32298
Build integration image with no open in remix and with reset script
acuarica May 16, 2024
47a2696
Improve docs
acuarica May 16, 2024
99f3162
Improve test setup
acuarica May 20, 2024
b4e40fd
Clean up unused test files
acuarica May 21, 2024
96e86d8
Restore baseline server tests
acuarica May 21, 2024
0f0c138
Restore GH job to run baseline tests
acuarica May 21, 2024
0310c8e
Fix CI after reincluding `ganache`
acuarica May 21, 2024
cfb2dff
Pin `ganache` dependency to avoid CI errors
acuarica May 21, 2024
ce19324
Fix lock file
acuarica May 21, 2024
faec589
Improve Tests section in `README`
acuarica May 21, 2024
d594754
Remove `axios` dependency and use native `fetch`
acuarica May 21, 2024
750cfb7
Rename chain ID
acuarica May 21, 2024
252223b
Fix `dryrun` bug when verifying multiple contracts
acuarica May 21, 2024
139b04f
Apply patch to release integration images
acuarica May 21, 2024
62ad806
Fix select-form select chain bug by applying a patch
acuarica May 21, 2024
1e68335
Mount config file
acuarica May 21, 2024
fc72eb3
Revert "Remove server to use upstream Sourcify"
acuarica May 21, 2024
10a190a
Normalize scripts naming
acuarica May 22, 2024
1bca8f9
Address some Nana's comments
acuarica May 22, 2024
893aa95
Improve Tools and Releases sections
acuarica May 22, 2024
29afdc6
Improve doc comments
acuarica May 23, 2024
250943a
Improve docs
acuarica May 23, 2024
a6d35eb
Refine docs
acuarica May 23, 2024
b0292f8
More on docs
acuarica May 23, 2024
5c78f9e
Refine docs
acuarica May 24, 2024
819894a
Move tools docs to own folder
acuarica May 24, 2024
ebb441a
Fix typo
acuarica May 24, 2024
99d3bcc
Improve docs
acuarica May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .dockerignore

This file was deleted.

8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Docker version tag to build and pull images
TAG=test

## Ports to access containers from the host
SERVER_PORT=5555
UI_PORT=3001
REPOSITORY_PORT=10000
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

23 changes: 0 additions & 23 deletions .eslintrc.js

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/release-image-to-github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ jobs:
context: ./ui
file: ./ui/Dockerfile
platforms: linux/amd64, linux/arm64
build-args: |
SERVER_URL=http://localhost:5002
REPOSITORY_SERVER_URL=http://localhost:10000
TAG=${{env.TAG}}
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:ui-${{env.TAG}}

Expand Down
49 changes: 33 additions & 16 deletions .github/workflows/release-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'true'
submodules: true
- name: Apply Sourcify server patch customizations
run: npm run server:patch
- name: Apply Sourcify repository patch customizations
run: npm run repository:patch

- name: Get tag
run: |
if [[ -v "${{ github.event.inputs.version }}" ]]; then
if [[ "${{ github.event.inputs.version }}" ]]; then
echo "TAG=${{ github.event.inputs.version }}" >> $GITHUB_ENV
else
echo "TAG=main" >> $GITHUB_ENV
fi

- name: Patch h5ai-nginx submodule
run: ./scripts/hedera-apply-h5ai-nginx-patch.sh

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -58,27 +59,43 @@ jobs:
context: ./ui
file: ./ui/Dockerfile
platforms: linux/amd64, linux/arm64
build-args: |
SERVER_URL=http://localhost:5002
REPOSITORY_SERVER_URL=http://localhost:10000
TAG=${{env.TAG}}
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:ui-${{env.TAG}}
tags: ${{ env.REGISTRY }}/${{ github.repository }}/ui:${{env.TAG}}

- name: Build and push SERVER image
uses: docker/build-push-action@v2
with:
context: .
file: ./src/Dockerfile.server
platforms: linux/amd64
context: ./sourcify

# The `scripts` context is used to `COPY` the reset network script into the `server` container.
# Use `additional_contexts` to access the `scripts` folder outside main context.
# See https://docs.docker.com/compose/compose-file/build/#additional_contexts for more details.
build-contexts: |
scripts=./scripts

# The `Dockerfile.server` used here is basically the same as the one provided by Sourcify.
# It adds instructions to include the reset network script into the container.
file: ./Dockerfile.server
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:server-${{env.TAG}}
tags: ${{ env.REGISTRY }}/${{ github.repository }}/server:${{env.TAG}}

- name: Build and Push REPOSITORY Image
uses: docker/build-push-action@v2
with:
context: ./h5ai-nginx

# From https://github.com/ethereum/sourcify/issues/1385
#
# The `repository` service provides a link to open each verified contract in Remix.
# However, for public self-hosted Sourcify instances (like in the case of Hedera) the _Open repo in Remix_ link does not work,
# given the Remix plugin only fetches contracts from https://repo.sourcify.dev.
#
# When `HIDE_OPEN_IN_REMIX` is set to 1, a patch to remove the link is applied.
# See https://github.com/sourcifyeth/h5ai-nginx/pull/5 for more details.
build-args: |
HIDE_OPEN_IN_REMIX=1
file: ./h5ai-nginx/Dockerfile
platforms: linux/amd64
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:repository-${{env.TAG}}
tags: ${{ env.REGISTRY }}/${{ github.repository }}/repository:${{env.TAG}}
75 changes: 26 additions & 49 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,85 +1,62 @@
name: Tests
name: Integration Tests

on:
workflow_dispatch:
pull_request:

jobs:

bytecode-utils-uts:
name: bytecode-utils unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npx lerna bootstrap && npx lerna run build
- run: cd packages/bytecode-utils && npm run test

contract-call-decoder-uts:
name: contract-call-decoder unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npx lerna bootstrap && npx lerna run build
- run: cd packages/contract-call-decoder && npm run test

lib-sourcify-uts:
name: lib-sourcify unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npx lerna bootstrap && npx lerna run build
- run: cd packages/lib-sourcify && npm run test

server-ganache-its:
server-ganache:
name: server over Ganache integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Apply Sourcify server patch customizations
run: npm run server:patch

- name: Compile Sourcify server
working-directory: ./sourcify
run: |
npm ci
npm run build:lerna
- run: npm ci
- run: npx lerna bootstrap && npx lerna run build
- run: npm run test:server

server-local-node-its:
server-local-node:
name: server over Hedera's local node integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci

- name: Provide environment variables
run: cp environments/.env.dev.hedera environments/.env
- name: Apply Sourcify server patch customizations
run: npm run server:patch

- name: Build hedera-sourcify server
run: npx lerna bootstrap && npx lerna run build
- run: npm ci

- name: Start Hedera Local Node
run: npm run local-node:start

- name: Start hedera-sourcify server
run: (npm run server:start&)
- name: Start Sourcify server
working-directory: ./sourcify
run: |
npm ci
npm run build:lerna
cp ../test/sourcify-chains.json ./services/server/dist/
(npm run server:start&)

- name: Wait for hedera-sourcify server
uses: iFaxity/wait-on-action@v1
with:
resource: http://127.0.0.1:5002/chains
resource: http://127.0.0.1:5555/chains

- name: Start tests
run: npm run test:hedera
28 changes: 3 additions & 25 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
.idea
.DS_Store
db/
node_modules/
mockRepository*
server.log
ui/node_modules/
ui/dist/
ui/.cache/
source-verify.dab
dist/
**/.env
**/.env-backup
**/*.key
stats**
tmp
metacoin-source-verify/
**/synced
**/sort.log
logs
**/too_big.txt
chain-tests-report/
coverage
!src/server/controllers/repository
environments/docker-config.json
/node_modules/

# Placeholder for volume mount point for the repository.
/data/
4 changes: 3 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[submodule "h5ai-nginx"]
path = h5ai-nginx
url = https://github.com/sourcifyeth/h5ai-nginx
ignore = dirty
[submodule "sourcify"]
path = sourcify
url = https://github.com/ethereum/sourcify.git
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

48 changes: 48 additions & 0 deletions Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#diff ./sourcify/services/server/Dockerfile Dockerfile.server
# Needs to be run from the project root context

# Builder image
FROM node:16.17.0-bullseye as builder

RUN mkdir -p /home/app
WORKDIR /home/app

COPY . .

# Install server's dependencies and build the server
RUN npm ci --workspace=sourcify-server --include-workspace-root
RUN npx lerna run build --scope sourcify-server

######################
## Production image ##
######################
FROM node:16.17.0-bullseye-slim as production

RUN mkdir -p /home/app/services/server

WORKDIR /home/app/
COPY package.json ./package.json
COPY package-lock.json ./package-lock.json
COPY lerna.json ./lerna.json
COPY nx.json ./nx.json

# Use `additional_contexts` in `compose.yaml` to access the `scripts` folder outside main context
# See https://docs.docker.com/compose/compose-file/build/#additional_contexts for more details
COPY --from=scripts ./hedera-reset-docker.sh ./

COPY --from=builder /home/app/packages/ ./packages/
COPY --from=builder /home/app/services/server/ ./services/server/

RUN npm ci --workspace=sourcify-server --include-workspace-root --omit=dev

LABEL org.opencontainers.image.source https://github.com/ethereum/sourcify
LABEL org.opencontainers.image.licenses MIT

# Set default value for ARG
ARG NODE_ENV=production

# Set environment variable
ENV NODE_ENV=${NODE_ENV}

WORKDIR /home/app/services/server
CMD ["npm", "start"]
Loading
Loading