Skip to content

Commit

Permalink
[feat] Pinner Docker image (#65)
Browse files Browse the repository at this point in the history
* add docker image for the pinner
* push to gar using gcr json creds
* add docker-compose.yml and expose pinner api port
* add ewm-das tester to docker compose.
* use 5080 port
* add legacy upload support
* add legacy calculate CID support
* add legacy download
* use only AMD platform
* push stable versioned only images

Signed-off-by: Pranay Valson <[email protected]>
Co-authored-by: tarassh <[email protected]>
Signed-off-by: Pranay Valson <[email protected]>
  • Loading branch information
tarassh authored and noslav committed Jan 25, 2025
1 parent 9759289 commit aba9b9b
Show file tree
Hide file tree
Showing 10 changed files with 493 additions and 10,024 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/build-gar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: build-gar

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
- "develop"
jobs:
ewm-das:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GCR
uses: docker/login-action@v2
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}

- uses: actions/checkout@v2
- name: Build & Publish the Docker image
run: |
docker buildx create --name builder --use --platform=linux/amd64 && docker buildx build --platform=linux/amd64 . -f Dockerfile.pinner -t us-docker.pkg.dev/covalent-project/network/ewm-das:latest --push
- name: Create .env file
run: |
touch .env
{
echo "W3_AGENT_KEY=${{ secrets.W3_AGENT_KEY }}"
echo "PROOF_OUT_HEX=${{ secrets.PROOF_OUT_HEX }}"
echo "W3_DELEGATION_FILE=${{ secrets.W3_DELEGATION_FILE }}"
} >> .env
cat .env
- name: Load .env file
uses: xom9ikk/[email protected]

- name: Run containers
run: docker compose --env-file ".env" -f "docker-compose-ci.yml" up --build --remove-orphans --exit-code-from ewm-das-tester

- name: Check running agent
run: docker inspect ewm-das

- name: Check running containers
run: docker ps

- name: Delete .env & bin files
run: |
rm -rf .env && rm -rf ./bin/block-ethereum
- name: Stop containers
if: always()
run: docker compose -f "docker-compose-ci.yml" down
37 changes: 37 additions & 0 deletions .github/workflows/tag-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: tag-release

on:
push:
tags:
- "v*.*.*"

jobs:
tagged-release:
name: Tagged Release
runs-on: "ubuntu-latest"

steps:
- name: Login to GCR
uses: docker/login-action@v2
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}

- uses: actions/checkout@v2

- name: Set env
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Build & Publish the Docker image
run: |
docker buildx create --name builder --use --platform=linux/amd64 && docker buildx build --platform=linux/amd64 . -f Dockerfile.pinner -t us-docker.pkg.dev/covalent-project/network/ewm-das:stable -t us-docker.pkg.dev/covalent-project/network/ewm-das:"${{ env.TAG }}" --push
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
draft: false
prerelease: false
files: |
*.zip
*.tar.gz
61 changes: 61 additions & 0 deletions Dockerfile.pinner
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Use an official Golang image as a base image
FROM golang:1.23-bullseye AS builder

# Set environment variables for CGO flags
ENV CGO_CFLAGS="-O2 -D__BLST_PORTABLE__"
ENV CGO_CXXFLAGS="-O2 -D__BLST_PORTABLE__"
ENV CGO_LDFLAGS="-O2 -D__BLST_PORTABLE__"

# Install necessary dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git make bash curl gcc g++ musl musl-dev musl-tools && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Set the working directory for the pinner
WORKDIR /go/src/pinner

# Clone the pinner repository
COPY . .

# Build the pinner
RUN CC=musl-gcc make build-pinner EXTRA_TAGS="-tags experimental"

# Create a minimal runtime image
FROM alpine:latest

# Install necessary dependencies
RUN apk update && apk add --no-cache bash nodejs npm git musl musl-dev curl \
&& npm install -g @web3-storage/[email protected] \
&& npm install -g crypto-random-string

# Copy the built pinner binary
COPY --from=builder /go/src/pinner/bin/pinner /usr/local/bin/pinner
RUN chmod +x /usr/local/bin/pinner

# Copy trusted setup files
COPY --from=builder /go/src/pinner/test/data/trusted_setup.txt /root/.covalent/trusted_setup.txt

# Copy test data
COPY --from=builder /go/src/pinner/test/data/specimen-result.json /root/.covalent/test/specimen-result.json
COPY --from=builder /go/src/pinner/scripts/das-pinner-tester.sh /root/.covalent/test/das-pinner-tester.sh
RUN chmod +x /root/.covalent/test/das-pinner-tester.sh

# Clean up
RUN apk del git && rm -rf /var/cache/apk/* /root/.npm /tmp/*

# Expose pinner API port
EXPOSE 5080

# Expose the default IPFS port
EXPOSE 4001

# Expose the default IPFS API port
EXPOSE 5001

# Expose the default IPFS Gateway port
EXPOSE 8080

HEALTHCHECK --interval=10s --timeout=5s CMD wget --no-verbose --tries=1 --spider localhost:5080/health

ENTRYPOINT [ "/bin/bash", "-l", "-c" ]
CMD [ "pinner --addr :5080 --w3-agent-key $W3_AGENT_KEY --w3-delegation-proof-path $W3_DELEGATION_FILE" ]
Loading

0 comments on commit aba9b9b

Please sign in to comment.