Skip to content

Commit c767504

Browse files
authored
feat: add Docker builds for eth2near (#955)
1 parent b8fd280 commit c767504

File tree

4 files changed

+142
-2
lines changed

4 files changed

+142
-2
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and Push eth2near Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
paths:
9+
- 'eth2near/**'
10+
- 'contracts/near/**'
11+
- '.github/workflows/eth2near-docker.yml'
12+
release:
13+
types: [published]
14+
workflow_dispatch:
15+
16+
env:
17+
REGISTRY: europe-west4-docker.pkg.dev
18+
PROJECT_ID: bridge-misc
19+
REPOSITORY: omni-bridge-docker-images
20+
21+
jobs:
22+
build-and-push:
23+
runs-on: warp-ubuntu-latest-x64-8x
24+
permissions:
25+
contents: read
26+
id-token: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v5
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Authenticate to Google Cloud
36+
uses: google-github-actions/auth@v2
37+
with:
38+
credentials_json: ${{ secrets.GCP_SA_KEY }}
39+
40+
- name: Configure Docker to use gcloud as credential helper
41+
run: gcloud auth configure-docker ${{ env.REGISTRY }}
42+
43+
- name: Extract metadata
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/eth2near
48+
tags: |
49+
type=ref,event=branch
50+
type=ref,event=pr
51+
type=semver,pattern={{version}}
52+
type=semver,pattern={{major}}.{{minor}}
53+
type=semver,pattern={{major}}
54+
type=sha,prefix={{branch}}
55+
type=raw,value=latest,enable={{is_default_branch}}
56+
57+
- name: Build and push Docker image
58+
id: build
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: .
62+
file: ./eth2near/Dockerfile
63+
push: true
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}
66+
platforms: linux/amd64
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max
69+
70+
- name: Output image digest
71+
run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}"

eth2near/.dockerignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Rust build artifacts
2+
target/
3+
**/*.rs.bk
4+
5+
# IDE files
6+
.vscode/
7+
.idea/
8+
*.swp
9+
*.swo
10+
11+
# OS files
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Git
16+
.git/
17+
.gitignore
18+
19+
# Documentation
20+
README.md
21+
*.md
22+
23+
# Test files
24+
tests/
25+
**/*_test.rs
26+
27+
# Development files
28+
.env
29+
.env.local
30+
.env.*.local
31+
32+
# Logs
33+
*.log
34+
35+
# Temporary files
36+
*.tmp
37+
*.temp

eth2near/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# syntax=docker/dockerfile:1
2+
FROM rust:1.84.0-bookworm AS builder
3+
4+
WORKDIR /app
5+
6+
# Copy everything
7+
COPY contracts/ ./contracts/
8+
COPY eth2near/ ./eth2near/
9+
10+
# Build with cache mounts
11+
WORKDIR /app/eth2near
12+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
13+
--mount=type=cache,target=/usr/local/cargo/git \
14+
--mount=type=cache,target=/app/eth2near/target \
15+
cargo build --release && \
16+
cp target/release/eth2-contract-init /tmp/ && \
17+
cp target/release/eth2_to_near_relay /tmp/
18+
19+
# === RUNTIME STAGE ===
20+
FROM debian:bookworm-slim AS runtime
21+
22+
RUN apt-get update && apt-get install -y \
23+
ca-certificates \
24+
libssl3 \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
COPY --from=builder /tmp/eth2-contract-init /usr/local/bin/
28+
COPY --from=builder /tmp/eth2_to_near_relay /usr/local/bin/
29+
30+
RUN useradd -m -u 1001 appuser
31+
USER appuser
32+
WORKDIR /app
33+
34+
CMD ["eth2_to_near_relay"]

0 commit comments

Comments
 (0)