Skip to content

Commit 3738dc1

Browse files
authored
Merge pull request #1190 from openmina/dw/fix-docker-openmina
Docker: fix openmina dockerfile and slightly improve it
2 parents 088ac35 + 191ed99 commit 3738dc1

File tree

6 files changed

+71
-30
lines changed

6 files changed

+71
-30
lines changed

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@ tools/heartbeats-processor/credentials/
1414
tools/heartbeats-processor/*.db
1515
# Ensure .sqlx files are included
1616
!tools/heartbeats-processor/.sqlx/
17+
18+
# Will be copied on demand in the Docker image, if necessary
19+
circuit-blobs
20+
21+
# GH workflows
22+
.github
23+
.idea
24+
25+
# Infrastructure
26+
helm
27+
28+
# Output of build-wasm
29+
pkg
30+
31+
# Outputs of build-tests-webrtc
32+
cargo-build-test.json
33+
tests.tsv

.github/workflows/docker.yaml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
name: Openmina Docker Build
1+
name: OpenMina Docker Build
22
on:
33
workflow_dispatch: {}
44
push:
5-
branches: [ main, develop ]
6-
tags: [ "*" ]
75
paths-ignore:
8-
# - ".github/**"
9-
- ".drone.yml"
106
- "helm/**"
117
- "*.md"
128
- "docs/**"
@@ -41,21 +37,31 @@ jobs:
4137
4238
- name: Login to Docker Hub
4339
uses: docker/login-action@v3
40+
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
4441
with:
4542
username: ${{ secrets.DOCKERHUB_USERNAME }}
4643
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4744

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

51-
- name: Build and push by digest
48+
- name: Build Docker image
5249
id: build
5350
uses: docker/build-push-action@v6
5451
with:
5552
context: .
5653
platforms: ${{ matrix.arch.platform }}
5754
cache-from: type=gha
5855
cache-to: type=gha,mode=max
56+
outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=false
57+
58+
- name: Push Docker image by digest
59+
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
60+
uses: docker/build-push-action@v6
61+
with:
62+
context: .
63+
platforms: ${{ matrix.arch.platform }}
64+
cache-from: type=gha
5965
outputs: type=image,name=${{ env.REGISTRY_NODE_IMAGE }},push-by-digest=true,name-canonical=true,push=true
6066

6167
- name: Export digest
@@ -74,6 +80,7 @@ jobs:
7480

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

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

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

150-
- name: Build and push by digest
158+
- name: Build Docker image
151159
id: build
152160
uses: docker/build-push-action@v6
153161
with:
@@ -157,6 +165,17 @@ jobs:
157165
BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }}
158166
cache-from: type=gha
159167
cache-to: type=gha,mode=max
168+
outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=false
169+
170+
- name: Push Docker image by digest
171+
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
172+
uses: docker/build-push-action@v6
173+
with:
174+
context: ./frontend
175+
platforms: ${{ matrix.arch.platform }}
176+
build-args: |
177+
BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }}
178+
cache-from: type=gha
160179
outputs: type=image,name=${{ env.REGISTRY_FRONTEND_IMAGE }},push-by-digest=true,name-canonical=true,push=true
161180

162181
- name: Export digest
@@ -178,11 +197,8 @@ jobs:
178197
matrix:
179198
configuration:
180199
- build_configuration: production
181-
# - build_configuration: compose
182-
# tag_suffix: ""
183-
# - build_configuration: staging
184-
# tag_suffix: ""
185200
runs-on: ubuntu-latest
201+
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push' }}
186202
needs:
187203
- build-openmina-frontend-image
188204
steps:
@@ -201,9 +217,6 @@ jobs:
201217
uses: docker/metadata-action@v5
202218
with:
203219
images: ${{ env.REGISTRY_FRONTEND_IMAGE }}
204-
# flavor: |
205-
# suffix=${{ matrix.configuration.tag_suffix }},onlatest=true
206-
# generate Docker tags based on the following events/attributes
207220
tags: |
208221
type=ref,event=branch
209222
type=sha,format=short

Dockerfile

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@ FROM rust:bullseye AS build
33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends protobuf-compiler && \
55
apt-get clean
6-
RUN rustup default 1.84 && rustup component add rustfmt
6+
77
WORKDIR /openmina
8+
9+
COPY rust-toolchain.toml .
10+
11+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
12+
RUN RUST_VERSION=$(grep 'channel = ' rust-toolchain.toml | \
13+
sed 's/channel = "\(.*\)"/\1/') && \
14+
rustup default "$RUST_VERSION" && \
15+
rustup component add rustfmt
16+
817
COPY . .
9-
# Build with cache mount
10-
RUN --mount=type=cache,target=/usr/local/cargo/registry \
11-
--mount=type=cache,target=/openmina/target,id=rust-target \
12-
cargo build --release --package=cli --bin=openmina && \
13-
cp -r /openmina/target/release /openmina/release-bin/
14-
15-
RUN --mount=type=cache,target=/usr/local/cargo/registry \
16-
--mount=type=cache,target=/openmina/target,id=rust-target \
17-
cargo build --release --features scenario-generators \
18-
--bin openmina-node-testing && \
19-
cp -r /openmina/target/release /openmina/testing-release-bin/
18+
19+
RUN make build-release && \
20+
mkdir -p /openmina/release-bin && \
21+
cp /openmina/target/release/openmina /openmina/release-bin/openmina
22+
23+
RUN make build-testing && \
24+
mkdir -p /openmina/testing-release-bin && \
25+
cp /openmina/target/release/openmina-node-testing \
26+
/openmina/testing-release-bin/openmina-node-testing
2027

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

2632
FROM debian:bullseye

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ build-ledger: download-circuits ## Build the ledger binary and library, requires
1616

1717
.PHONY: build-release
1818
build-release: ## Build the project in release mode
19-
cargo build --release --bin openmina
19+
cargo build --release --package=cli --bin openmina
20+
21+
.PHONY: build-testing
22+
build-testing: ## Build the testing binary with scenario generators
23+
cargo build --release --features scenario-generators --bin openmina-node-testing
2024

2125
.PHONY: build-tests-webrtc
2226
build-tests-webrtc: ## Build tests for WebRTC

rust-toolchain

Lines changed: 0 additions & 1 deletion
This file was deleted.

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "1.84"

0 commit comments

Comments
 (0)