Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,20 @@ tools/heartbeats-processor/credentials/
tools/heartbeats-processor/*.db
# Ensure .sqlx files are included
!tools/heartbeats-processor/.sqlx/

# Will be copied on demand in the Docker image, if necessary
circuit-blobs

# GH workflows
.github
.idea

# Infrastructure
helm

# Output of build-wasm
pkg

# Outputs of build-tests-webrtc
cargo-build-test.json
tests.tsv
41 changes: 27 additions & 14 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: Openmina Docker Build
name: OpenMina Docker Build
on:
workflow_dispatch: {}
push:
branches: [ main, develop ]
tags: [ "*" ]
paths-ignore:
# - ".github/**"
- ".drone.yml"
- "helm/**"
- "*.md"
- "docs/**"
Expand Down Expand Up @@ -41,21 +37,31 @@ jobs:

- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push by digest
- name: Build Docker image
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.arch.platform }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=false

- name: Push Docker image by digest
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.arch.platform }}
cache-from: type=gha
outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
Expand All @@ -74,6 +80,7 @@ jobs:

merge-openmina-node-image:
runs-on: ubuntu-latest
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
needs:
- build-openmina-node-image
steps:
Expand Down Expand Up @@ -140,14 +147,15 @@ jobs:

- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push by digest
- name: Build Docker image
id: build
uses: docker/build-push-action@v6
with:
Expand All @@ -157,6 +165,17 @@ jobs:
BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=false

- name: Push Docker image by digest
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
uses: docker/build-push-action@v6
with:
context: ./frontend
platforms: ${{ matrix.arch.platform }}
build-args: |
BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }}
cache-from: type=gha
outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
Expand All @@ -178,11 +197,8 @@ jobs:
matrix:
configuration:
- build_configuration: production
# - build_configuration: compose
# tag_suffix: ""
# - build_configuration: staging
# tag_suffix: ""
runs-on: ubuntu-latest
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
needs:
- build-openmina-frontend-image
steps:
Expand All @@ -201,9 +217,6 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_FRONTEND_IMAGE }}
# flavor: |
# suffix=${{ matrix.configuration.tag_suffix }},onlatest=true
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=sha,format=short
Expand Down
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@ FROM rust:bullseye AS build
RUN apt-get update && \
apt-get install -y --no-install-recommends protobuf-compiler && \
apt-get clean
RUN rustup default 1.84 && rustup component add rustfmt

WORKDIR /openmina

COPY rust-toolchain.toml .

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN RUST_VERSION=$(grep 'channel = ' rust-toolchain.toml | \
sed 's/channel = "\(.*\)"/\1/') && \
rustup default "$RUST_VERSION" && \
rustup component add rustfmt

COPY . .
# Build with cache mount
RUN --mount=type=cache,target=/usr/local/cargo/registry \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker build -t openmina/openmina:6945ec6b .
[+] Building 399.3s (21/21) FINISHED 

I guess it is fine for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--mount=type=cache,target=/openmina/target,id=rust-target \
cargo build --release --package=cli --bin=openmina && \
cp -r /openmina/target/release /openmina/release-bin/

RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/openmina/target,id=rust-target \
cargo build --release --features scenario-generators \
--bin openmina-node-testing && \
cp -r /openmina/target/release /openmina/testing-release-bin/

RUN make build-release && \
mkdir -p /openmina/release-bin && \
cp /openmina/target/release/openmina /openmina/release-bin/openmina

RUN make build-testing && \
mkdir -p /openmina/testing-release-bin && \
cp /openmina/target/release/openmina-node-testing \
/openmina/testing-release-bin/openmina-node-testing

# necessary for proof generation when running a block producer.
RUN git clone --depth 1 \
https://github.com/openmina/circuit-blobs.git && \
RUN make download-circuits && \
rm -rf circuit-blobs/berkeley_rc1 circuit-blobs/*/tests

FROM debian:bullseye
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ build-ledger: download-circuits ## Build the ledger binary and library, requires

.PHONY: build-release
build-release: ## Build the project in release mode
cargo build --release --bin openmina
cargo build --release --package=cli --bin openmina

.PHONY: build-testing
build-testing: ## Build the testing binary with scenario generators
cargo build --release --features scenario-generators --bin openmina-node-testing

.PHONY: build-tests-webrtc
build-tests-webrtc: ## Build tests for WebRTC
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.84"