Skip to content

Commit

Permalink
Update docker friendly (#78)
Browse files Browse the repository at this point in the history
* tweak build

* build Docker image

* ci build Docker image

* format dockerfile

---------

Co-authored-by: Timofey Luin <timofey.luin@gmail.com>
  • Loading branch information
eedygreen and nulltea authored Sep 5, 2024
1 parent 58478f9 commit d3dc4ce
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 51 deletions.
86 changes: 51 additions & 35 deletions .github/workflows/spectre-test.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
name: Spectre Deploy
# The Licensed Work is (c) 2022 Sygma
# SPDX-License-Identifier: LGPL-3.0-only

name: Spectre Testnet

on:
push:
branches:
- main
- docker-friendly
tags:
- 'v*.*.*'

env:
REGISTRY: 'ghcr.io'
TAG: 'latest'

jobs:
deploy:
push:
name: push
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4
- name: checkout the source code
uses: actions/checkout@v4

- name: initialize all submodules
run: git submodule update --init --recursive

- name: deployments
uses: burnett01/rsync-deployments@6.0.0
with:
switches: -avzr --delete --exclude '.git'
path: ./
remote_path: /home/ubuntu/Spectre
remote_host: ${{ secrets.ACTIONS_HOST }}
remote_user: ${{ secrets.ACTIONS_USER }}
remote_key: ${{ secrets.ACTIONS_CONNECTIONS }}

- name: Spectre
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.ACTIONS_HOST }}
username: ${{ secrets.ACTIONS_USER }}
key: ${{ secrets.ACTIONS_CONNECTIONS }}
script: |
sudo systemctl daemon-reload
sudo systemctl restart spectre
- name: slack notify
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,job,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: login to ghcr
id: ghcr
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Extract Version
run: echo "VERSION=${GITHUBREF#refs/tags/}" >> $GITHUB_ENV

- name: build / tag / push docker image into ghcr
id: build-and-push-tag
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.TAG }},${{ env.REGISTRY }}/${{ github.repository }}:${{ env.VERSION }}

# - name: slack notify
# uses: 8398a7/action-slack@v3
# with:
# status: ${{ job.status }}
# fields: repo,message,commit,author,action,job,eventName,ref,workflow
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# if: always()
44 changes: 28 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
# syntax=docker/dockerfile:1.3-labs

FROM alpine:3.6 as alpine
RUN apk add -U --no-cache ca-certificates

FROM rustlang/rust:nightly-slim as builder
ADD . /src
WORKDIR /src
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
RUN apt-get update -y
RUN apt-get install lsb-release software-properties-common gnupg -y
RUN apt-get install -y build-essential pkg-config libssl-dev curl wget git
RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
RUN git submodule update --init --recursive
RUN cargo build -r -p spectre-prover

FROM scratch
COPY --from=builder /src/target/release/spectre-prover-cli .
ENTRYPOINT [./spectre-prover-cli rpc --port 3000 --spec testnet]
COPY . /
WORKDIR /
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
RUN <<-EOF
apt-get update -y
apt-get install lsb-release software-properties-common gnupg -y
apt-get install -y build-essential \
pkg-config \
libssl-dev \
wget \
git
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
git submodule update --init --recursive
cargo build -r -p spectre-prover
EOF

FROM debian:stable
ENV RUST_BACKTRACE=full
WORKDIR /
COPY /lightclient-circuits/config/ /lightclient-circuits/config/
COPY --from=builder /target/release/spectre-prover-cli /spectre-prover-cli
RUN <<-EOF
apt-get update -y
apt-get install libssl-dev -y
chmod +x /spectre-prover-cli
mkdir -p /build /params
EOF
ENTRYPOINT ["./spectre-prover-cli", "rpc", "--port", "3000"]
CMD ["--spec", "testnet"]

0 comments on commit d3dc4ce

Please sign in to comment.