Skip to content

Commit 8a190e4

Browse files
authored
Merge pull request #10 from lambdaclass/docker-image
docker image
1 parent 420f681 commit 8a190e4

File tree

12 files changed

+123
-8
lines changed

12 files changed

+123
-8
lines changed

.github/workflows/docker-image.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Demo Push
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
pull_request:
10+
11+
env:
12+
IMAGE_NAME: ethrex_l2_hub
13+
14+
jobs:
15+
# This pushes the image to GitHub Packages.
16+
push:
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
packages: write
21+
contents: read
22+
steps:
23+
- uses: actions/checkout@v5
24+
25+
- name: Build image
26+
working-directory: ./app
27+
# TODO: add step to compile the contracts using rex
28+
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
29+
30+
- name: Log in to registry
31+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
32+
33+
- name: Push image
34+
run: |
35+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
36+
37+
# This changes all uppercase characters to lowercase.
38+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
39+
# This strips the git ref prefix from the version.
40+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
41+
# This strips the "v" prefix from the tag name.
42+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
43+
# This uses the Docker `latest` tag convention.
44+
[ "$VERSION" == "main" ] && VERSION=latest
45+
echo IMAGE_ID=$IMAGE_ID
46+
echo VERSION=$VERSION
47+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
48+
docker push $IMAGE_ID:$VERSION

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,37 @@ The app should now be running at `http://localhost:5173`
125125
make run-front
126126
```
127127

128+
## Running with Docker
129+
130+
Pull the image from the registry with
131+
132+
```bash
133+
docker pull ghcr.io/lambdaclass/ethrex_l2_hub:merge
134+
```
135+
136+
Run the image with
137+
138+
```bash
139+
docker run --name ethrex_l2_hub -p 5173:5173 --env-file /path/to/.env ghcr.io/lambdaclass/ethrex_l2_hub:merge
140+
```
141+
142+
The `.env` file must contain the following environment variables (make sure to replace them with the actual values)
143+
144+
```.env
145+
VITE_L1_NAME="Ethrex L1 Local"
146+
VITE_L1_RPC_URL=http://host.docker.internal:8545
147+
VITE_L1_CHAIN_ID=9
148+
VITE_L1_BRIDGE_ADDRESS=0xebc31Eff9D9f5F63F65A68734816b7De1256845B
149+
VITE_L2_NAME="Ethrex L2 Local"
150+
VITE_L2_RPC_URL=http://host.docker.internal:1729
151+
VITE_L2_CHAIN_ID=65536999
152+
VITE_L2_BRIDGE_ADDRESS=0x000000000000000000000000000000000000ffff
153+
VITE_WALLETCONNECT_PROJECT_ID=
154+
VITE_DELEGATION_CONTRACT_ADDRESS=0x00e29d532f1c62a923ee51ee439bfc1500b1ce4d
155+
VITE_TEST_TOKEN_CONTRACT_ADDRESS=0x4b8a3d616d9146d9ec66a33b76d63612eabede02
156+
157+
```
158+
128159
## Features
129160

130161
### L1 ↔ L2 Bridge

app/.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
build
3+
npm-debug.log

app/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM node:22-alpine3.21 AS build
2+
3+
# Set the working directory inside the container
4+
WORKDIR /usr/src/app
5+
6+
# Copy package.json and package-lock.json into the container
7+
COPY package*.json ./
8+
9+
# node-gyp requires python3
10+
RUN apk add --no-cache python3 make g++
11+
12+
# Install dependencies using npm
13+
RUN npm install
14+
15+
# Copy the project files into the working directory
16+
COPY . .
17+
18+
EXPOSE 5173
19+
20+
# Build and start the app
21+
# TODO: change this so that the app can replace the environment variables at runtime
22+
# without the need to build the app every time
23+
ENTRYPOINT ["npm", "run", "dev"]

app/abi/Delegation.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/abi/TestToken.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "vite --host",
88
"build": "tsc -b && vite build",
99
"lint": "eslint .",
10-
"preview": "vite preview"
10+
"preview": "vite preview",
11+
"build:preview": "npm run build && npm run preview"
1112
},
1213
"dependencies": {
1314
"@tailwindcss/vite": "^4.0.14",

app/src/components/Deposit/Deposit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useDeposit, useWatchDepositInitiated } from "../hooks/deposit";
55

66
export const Deposit: React.FC = () => {
77
const [amount, setAmount] = useState<string>("");
8-
const { address } = useAccount();
8+
useAccount();
99
const { data, isPending, isSuccess: isTxSuccess, deposit } = useDeposit({ amount: parseEther(amount) })
1010
const { isLoading, isSuccess: isTxReciptSuccess } = useWaitForTransactionReceipt({ hash: data })
1111
const { switchChain } = useSwitchChain()

app/src/config/passkey_config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ client.request = async ({ method, params }) => {
1717
method = "ethrex_sendTransaction";
1818
}
1919

20-
return base_request({ method, params });
20+
return base_request({ method: method as any, params: params as any });
2121
};
2222

2323
export type Client = typeof client;

app/src/utils/passkeyAccounts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
waitForTransactionReceipt,
1616
writeContract,
1717
} from "viem/actions";
18-
import Delegation from "../../../solc_out/Delegation.json";
18+
import Delegation from "../../abi/Delegation.json";
1919

2020
export const signUp = async ({
2121
client,

0 commit comments

Comments
 (0)