Skip to content

Commit

Permalink
update docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
Liuhaai committed Nov 21, 2024
1 parent dfd0ba6 commit 8407b36
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 4 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/gnark-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: build_gnark-server_image

on:
push:
paths:
- 'gnark-server/**'
tags:
- v*.*.*

env:
REGISTRY: ghcr.io
IMAGE_NAME: iotexproject/gnarkserver

jobs:
build_docker_image:
timeout-minutes: 1440
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
permissions:
contents: read
packages: write
id-token: write

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./gnark-server/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
*/node_modules/
*/node_modules/
**/bin/
11 changes: 11 additions & 0 deletions gnark-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.23-alpine AS builder

WORKDIR /app
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 go build -o /gnark-server ./cmd/main.go

FROM alpine:3.17
COPY --from=builder /gnark-server /gnark-server
EXPOSE 4004
ENTRYPOINT ["/gnark-server"]
10 changes: 9 additions & 1 deletion gnark-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ proto:
--go_opt=paths=source_relative \
--go-grpc_out=. \
--go-grpc_opt=paths=source_relative \
../proto/vm_runtime.proto
../proto/vm_runtime.proto

.PHONY: build
build:
go build -o bin/gnark-server ./cmd/main.go

.PHONY: docker
docker:
docker build -t gnark-server:latest .
2 changes: 1 addition & 1 deletion gnark-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This server provides a gRPC interface for:
## Quick Start
1. Start the server:
```
go run cmd/main.go --port 8080
go run cmd/main.go --port 4004
```

2. The server will listen for gRPC requests on the specified port.
Expand Down
2 changes: 1 addition & 1 deletion gnark-server/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var (
port = flag.Int("port", 8080, "The server port")
port = flag.Int("port", 4004, "The server port")
)

func main() {
Expand Down

0 comments on commit 8407b36

Please sign in to comment.