Skip to content

Commit

Permalink
feat: use upstream Sourcify images (#164)
Browse files Browse the repository at this point in the history
Signed-off-by: beeradb <294617+beeradb@users.noreply.github.com>
  • Loading branch information
acuarica authored and beeradb committed Jun 5, 2024
1 parent ab8fb63 commit c9125ef
Show file tree
Hide file tree
Showing 149 changed files with 12,583 additions and 129,208 deletions.
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

0 comments on commit c9125ef

Please sign in to comment.