Skip to content

Commit aba9b9b

Browse files
tarasshnoslav
authored andcommitted
[feat] Pinner Docker image (#65)
* 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 <pranay.valson@gmail.com> Co-authored-by: tarassh <tshchybo@gmail.com> Signed-off-by: Pranay Valson <pranay.valson@gmail.com>
1 parent 9759289 commit aba9b9b

File tree

10 files changed

+493
-10024
lines changed

10 files changed

+493
-10024
lines changed

.github/workflows/build-gar.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: build-gar
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- "main"
10+
- "develop"
11+
jobs:
12+
ewm-das:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Cancel Previous Runs
16+
uses: styfle/cancel-workflow-action@0.6.0
17+
with:
18+
access_token: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Login to GCR
20+
uses: docker/login-action@v2
21+
with:
22+
registry: us-docker.pkg.dev
23+
username: _json_key
24+
password: ${{ secrets.GCR_JSON_KEY }}
25+
26+
- uses: actions/checkout@v2
27+
- name: Build & Publish the Docker image
28+
run: |
29+
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
30+
31+
- name: Create .env file
32+
run: |
33+
touch .env
34+
{
35+
echo "W3_AGENT_KEY=${{ secrets.W3_AGENT_KEY }}"
36+
echo "PROOF_OUT_HEX=${{ secrets.PROOF_OUT_HEX }}"
37+
echo "W3_DELEGATION_FILE=${{ secrets.W3_DELEGATION_FILE }}"
38+
} >> .env
39+
cat .env
40+
41+
- name: Load .env file
42+
uses: xom9ikk/dotenv@v1.0.2
43+
44+
- name: Run containers
45+
run: docker compose --env-file ".env" -f "docker-compose-ci.yml" up --build --remove-orphans --exit-code-from ewm-das-tester
46+
47+
- name: Check running agent
48+
run: docker inspect ewm-das
49+
50+
- name: Check running containers
51+
run: docker ps
52+
53+
- name: Delete .env & bin files
54+
run: |
55+
rm -rf .env && rm -rf ./bin/block-ethereum
56+
57+
- name: Stop containers
58+
if: always()
59+
run: docker compose -f "docker-compose-ci.yml" down

.github/workflows/tag-release.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: tag-release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
tagged-release:
10+
name: Tagged Release
11+
runs-on: "ubuntu-latest"
12+
13+
steps:
14+
- name: Login to GCR
15+
uses: docker/login-action@v2
16+
with:
17+
registry: us-docker.pkg.dev
18+
username: _json_key
19+
password: ${{ secrets.GCR_JSON_KEY }}
20+
21+
- uses: actions/checkout@v2
22+
23+
- name: Set env
24+
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
25+
26+
- name: Build & Publish the Docker image
27+
run: |
28+
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
29+
30+
- uses: "marvinpinto/action-automatic-releases@latest"
31+
with:
32+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
33+
draft: false
34+
prerelease: false
35+
files: |
36+
*.zip
37+
*.tar.gz

Dockerfile.pinner

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Use an official Golang image as a base image
2+
FROM golang:1.23-bullseye AS builder
3+
4+
# Set environment variables for CGO flags
5+
ENV CGO_CFLAGS="-O2 -D__BLST_PORTABLE__"
6+
ENV CGO_CXXFLAGS="-O2 -D__BLST_PORTABLE__"
7+
ENV CGO_LDFLAGS="-O2 -D__BLST_PORTABLE__"
8+
9+
# Install necessary dependencies
10+
RUN apt-get update && apt-get install -y --no-install-recommends \
11+
git make bash curl gcc g++ musl musl-dev musl-tools && \
12+
apt-get clean && rm -rf /var/lib/apt/lists/*
13+
14+
# Set the working directory for the pinner
15+
WORKDIR /go/src/pinner
16+
17+
# Clone the pinner repository
18+
COPY . .
19+
20+
# Build the pinner
21+
RUN CC=musl-gcc make build-pinner EXTRA_TAGS="-tags experimental"
22+
23+
# Create a minimal runtime image
24+
FROM alpine:latest
25+
26+
# Install necessary dependencies
27+
RUN apk update && apk add --no-cache bash nodejs npm git musl musl-dev curl \
28+
&& npm install -g @web3-storage/w3cli@v7.9.1 \
29+
&& npm install -g crypto-random-string
30+
31+
# Copy the built pinner binary
32+
COPY --from=builder /go/src/pinner/bin/pinner /usr/local/bin/pinner
33+
RUN chmod +x /usr/local/bin/pinner
34+
35+
# Copy trusted setup files
36+
COPY --from=builder /go/src/pinner/test/data/trusted_setup.txt /root/.covalent/trusted_setup.txt
37+
38+
# Copy test data
39+
COPY --from=builder /go/src/pinner/test/data/specimen-result.json /root/.covalent/test/specimen-result.json
40+
COPY --from=builder /go/src/pinner/scripts/das-pinner-tester.sh /root/.covalent/test/das-pinner-tester.sh
41+
RUN chmod +x /root/.covalent/test/das-pinner-tester.sh
42+
43+
# Clean up
44+
RUN apk del git && rm -rf /var/cache/apk/* /root/.npm /tmp/*
45+
46+
# Expose pinner API port
47+
EXPOSE 5080
48+
49+
# Expose the default IPFS port
50+
EXPOSE 4001
51+
52+
# Expose the default IPFS API port
53+
EXPOSE 5001
54+
55+
# Expose the default IPFS Gateway port
56+
EXPOSE 8080
57+
58+
HEALTHCHECK --interval=10s --timeout=5s CMD wget --no-verbose --tries=1 --spider localhost:5080/health
59+
60+
ENTRYPOINT [ "/bin/bash", "-l", "-c" ]
61+
CMD [ "pinner --addr :5080 --w3-agent-key $W3_AGENT_KEY --w3-delegation-proof-path $W3_DELEGATION_FILE" ]

0 commit comments

Comments
 (0)