Skip to content

Commit 1849d84

Browse files
authored
Merge pull request #1183 from openmina/dw/add-hadolint
CI: lint dockerfiles
2 parents dced60e + a0221d1 commit 1849d84

File tree

13 files changed

+277
-90
lines changed

13 files changed

+277
-90
lines changed

.github/workflows/lint.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,19 @@ jobs:
4747
components: clippy, rustfmt
4848
- name: Run transaction Fuzzing check
4949
run: make check-tx-fuzzing
50+
51+
hadolint:
52+
name: Hadolint - ${{ matrix.os }}
53+
runs-on: ${{ matrix.os }}
54+
strategy:
55+
matrix:
56+
os: [ubuntu-latest]
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Install hadolint
60+
run: |
61+
wget -O /tmp/hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64
62+
chmod +x /tmp/hadolint
63+
sudo mv /tmp/hadolint /usr/local/bin/hadolint
64+
- name: Run hadolint
65+
run: make lint-dockerfiles

Dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM rust:bullseye AS build
2-
RUN apt-get update && apt-get install -y protobuf-compiler && apt-get clean
2+
# hadolint ignore=DL3008
3+
RUN apt-get update && \
4+
apt-get install -y --no-install-recommends protobuf-compiler && \
5+
apt-get clean
36
RUN rustup default 1.84 && rustup component add rustfmt
47
WORKDIR /openmina
58
COPY . .
@@ -11,21 +14,30 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
1114

1215
RUN --mount=type=cache,target=/usr/local/cargo/registry \
1316
--mount=type=cache,target=/openmina/target,id=rust-target \
14-
cargo build --release --features scenario-generators --bin openmina-node-testing && \
17+
cargo build --release --features scenario-generators \
18+
--bin openmina-node-testing && \
1519
cp -r /openmina/target/release /openmina/testing-release-bin/
1620

1721
# necessary for proof generation when running a block producer.
18-
RUN git clone --depth 1 https://github.com/openmina/circuit-blobs.git \
19-
&& rm -rf circuit-blobs/berkeley_rc1 circuit-blobs/*/tests
22+
RUN git clone --depth 1 \
23+
https://github.com/openmina/circuit-blobs.git && \
24+
rm -rf circuit-blobs/berkeley_rc1 circuit-blobs/*/tests
2025

2126
FROM debian:bullseye
22-
RUN apt-get update && apt-get install -y libjemalloc2 libssl1.1 libpq5 curl jq procps && apt-get clean
27+
# hadolint ignore=DL3008
28+
RUN apt-get update && \
29+
apt-get install -y --no-install-recommends \
30+
libjemalloc2 libssl1.1 libpq5 curl jq procps && \
31+
apt-get clean && \
32+
rm -rf /var/lib/apt/lists/*
2333

2434
COPY --from=build /openmina/release-bin/openmina /usr/local/bin/
25-
COPY --from=build /openmina/testing-release-bin/openmina-node-testing /usr/local/bin/
35+
COPY --from=build /openmina/testing-release-bin/openmina-node-testing \
36+
/usr/local/bin/
2637

2738
RUN mkdir -p /usr/local/lib/openmina/circuit-blobs
28-
COPY --from=build /openmina/circuit-blobs/ /usr/local/lib/openmina/circuit-blobs/
39+
COPY --from=build /openmina/circuit-blobs/ \
40+
/usr/local/lib/openmina/circuit-blobs/
2941

3042
EXPOSE 3000
3143
EXPOSE 8302

Makefile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ format-md: ## Format all markdown files to wrap at 80 characters
9595
lint: ## Run linter (clippy)
9696
cargo clippy --all-targets -- -D warnings --allow clippy::mutable_key_type
9797

98+
.PHONY: lint-dockerfiles
99+
lint-dockerfiles: ## Check all Dockerfiles using hadolint
100+
@if [ "$$GITHUB_ACTIONS" = "true" ]; then \
101+
OUTPUT=$$(find . -name "Dockerfile*" -type f -exec hadolint {} \;); \
102+
if [ -n "$$OUTPUT" ]; then \
103+
echo "$$OUTPUT"; \
104+
exit 1; \
105+
fi; \
106+
else \
107+
OUTPUT=$$(find . -name "Dockerfile*" -type f -exec sh -c 'docker run --rm -i hadolint/hadolint < "$$1"' _ {} \;); \
108+
if [ -n "$$OUTPUT" ]; then \
109+
echo "$$OUTPUT"; \
110+
exit 1; \
111+
fi; \
112+
fi
113+
98114
.PHONY: setup-wasm-toolchain
99115
setup-wasm-toolchain: ## Setup the WebAssembly toolchain, using nightly
100116
@ARCH=$$(uname -m); \
@@ -133,3 +149,66 @@ test-release: ## Run tests in release mode
133149
.PHONY: test-vrf
134150
test-vrf: ## Run VRF tests, requires nightly Rust
135151
@cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time
152+
153+
# Docker build targets
154+
DOCKER_ORG ?= openmina
155+
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD)
156+
157+
.PHONY: docker-build-all
158+
docker-build-all: docker-build-bootstrap-sandbox docker-build-debugger \
159+
docker-build-frontend docker-build-fuzzing docker-build-heartbeats-processor \
160+
docker-build-light docker-build-light-focal docker-build-openmina \
161+
docker-build-openmina-testing docker-build-producer-dashboard \
162+
docker-build-test ## Build all Docker images
163+
164+
.PHONY: docker-build-bootstrap-sandbox
165+
docker-build-bootstrap-sandbox: ## Build bootstrap sandbox Docker image
166+
docker build -t $(DOCKER_ORG)/openmina-bootstrap-sandbox:$(GIT_COMMIT) \
167+
tools/bootstrap-sandbox/
168+
169+
.PHONY: docker-build-debugger
170+
docker-build-debugger: ## Build debugger Docker image
171+
docker build -t $(DOCKER_ORG)/openmina-debugger:$(GIT_COMMIT) \
172+
-f node/testing/docker/Dockerfile.debugger node/testing/docker/
173+
174+
.PHONY: docker-build-frontend
175+
docker-build-frontend: ## Build frontend Docker image
176+
docker build -t $(DOCKER_ORG)/openmina-frontend:$(GIT_COMMIT) frontend/
177+
178+
.PHONY: docker-build-fuzzing
179+
docker-build-fuzzing: ## Build fuzzing Docker image
180+
docker build -t $(DOCKER_ORG)/openmina-fuzzing:$(GIT_COMMIT) tools/fuzzing/
181+
182+
.PHONY: docker-build-heartbeats-processor
183+
docker-build-heartbeats-processor: ## Build heartbeats processor Docker image
184+
docker build -t $(DOCKER_ORG)/openmina-heartbeats-processor:$(GIT_COMMIT) \
185+
tools/heartbeats-processor/
186+
187+
.PHONY: docker-build-light
188+
docker-build-light: ## Build light Docker image
189+
docker build -t $(DOCKER_ORG)/openmina-light:$(GIT_COMMIT) \
190+
-f node/testing/docker/Dockerfile.light node/testing/docker/
191+
192+
.PHONY: docker-build-light-focal
193+
docker-build-light-focal: ## Build light focal Docker image
194+
docker build -t $(DOCKER_ORG)/openmina-light-focal:$(GIT_COMMIT) \
195+
-f node/testing/docker/Dockerfile.light.focal node/testing/docker/
196+
197+
.PHONY: docker-build-openmina
198+
docker-build-openmina: ## Build main OpenMina Docker image
199+
docker build -t $(DOCKER_ORG)/openmina:$(GIT_COMMIT) .
200+
201+
.PHONY: docker-build-openmina-testing
202+
docker-build-openmina-testing: ## Build OpenMina testing Docker image
203+
docker build -t $(DOCKER_ORG)/openmina-testing:$(GIT_COMMIT) \
204+
-f node/testing/docker/Dockerfile.openmina node/testing/docker/
205+
206+
.PHONY: docker-build-producer-dashboard
207+
docker-build-producer-dashboard: ## Build producer dashboard Docker image
208+
docker build -t $(DOCKER_ORG)/openmina-producer-dashboard:$(GIT_COMMIT) \
209+
-f docker/producer-dashboard/Dockerfile .
210+
211+
.PHONY: docker-build-test
212+
docker-build-test: ## Build test Docker image
213+
docker build -t $(DOCKER_ORG)/openmina-test:$(GIT_COMMIT) \
214+
-f node/testing/docker/Dockerfile.test node/testing/docker/

docker/producer-dashboard/Dockerfile

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ WORKDIR /usr/src/openmina-producer-dashboard
44

55
COPY ../ .
66

7-
RUN cd producer-dashboard && SQLX_OFFLINE=true cargo install --path .
7+
WORKDIR /usr/src/openmina-producer-dashboard/producer-dashboard
8+
RUN SQLX_OFFLINE=true cargo install --path .
89

910
FROM ubuntu:noble AS mina-builder
1011

11-
RUN apt-get update && apt-get install -y openssl ca-certificates
12+
# hadolint ignore=DL3008
13+
RUN apt-get update && \
14+
apt-get install -y --no-install-recommends openssl ca-certificates
1215

1316
# Build mina from source
17+
# hadolint ignore=DL3008
1418
RUN apt-get update && \
1519
apt-get -y --no-install-recommends install \
1620
libboost-dev \
@@ -37,16 +41,18 @@ RUN apt-get update && \
3741
unzip \
3842
rsync
3943

40-
41-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
44+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
45+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
46+
sh -s -- -y
4247

4348
WORKDIR /go
4449
RUN git clone https://github.com/MinaProtocol/mina.git
4550

4651
ENV DUNE_PROFILE=devnet
4752

4853
WORKDIR /go/mina
49-
COPY ../docker/producer-dashboard/output_binprot_breadcrumbs.patch .
54+
COPY ../docker/producer-dashboard/output_binprot_breadcrumbs.patch \
55+
.
5056
RUN git checkout 3.0.1 && \
5157
git submodule update --init --recursive && \
5258
git config --local --add submodule.recurse true
@@ -55,34 +61,49 @@ RUN git apply ./output_binprot_breadcrumbs.patch
5561

5662
# RUN make libp2p_helper
5763

58-
RUN curl -s -L https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux -o /usr/local/bin/opam && chmod +x /usr/local/bin/opam
64+
RUN curl -s -L \
65+
https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux \
66+
-o /usr/local/bin/opam && \
67+
chmod +x /usr/local/bin/opam
5968

69+
# hadolint ignore=DL3008
6070
RUN apt-get -y --no-install-recommends install m4 pkg-config
6171

62-
RUN opam init --disable-sandboxing
63-
RUN opam switch create .
64-
RUN eval $(opam config env)
65-
RUN opam switch import -y opam.export
66-
RUN ./scripts/pin-external-packages.sh
72+
RUN opam init --disable-sandboxing && \
73+
opam switch create . && \
74+
eval "$(opam config env)" && \
75+
opam switch import -y opam.export && \
76+
./scripts/pin-external-packages.sh
6777

68-
RUN curl -L https://go.dev/dl/go1.19.linux-amd64.tar.gz -o go1.19.tar.gz \
69-
&& tar -C /usr/local -xzf go1.19.tar.gz \
70-
&& rm go1.19.tar.gz
78+
RUN curl -L https://go.dev/dl/go1.19.linux-amd64.tar.gz \
79+
-o go1.19.tar.gz && \
80+
tar -C /usr/local -xzf go1.19.tar.gz && \
81+
rm go1.19.tar.gz
7182
ENV PATH="/usr/local/go/bin:${PATH}"
7283
RUN make libp2p_helper
7384

7485
ENV PATH="/root/.cargo/bin:${PATH}"
86+
# hadolint ignore=DL3008
7587
RUN apt-get -y --no-install-recommends install zlib1g-dev
76-
RUN eval $(opam config env) && make build_all_sigs
77-
# RUN /bin/bash -c "source ~/.cargo/env && eval $(opam config env) && make build_all_sigs"
88+
RUN eval "$(opam config env)" && make build_all_sigs
89+
# RUN /bin/bash -c "source ~/.cargo/env && eval $(opam config env) && \
90+
# make build_all_sigs"
7891

7992
FROM ubuntu:noble
8093

81-
RUN apt-get update && apt-get install -y libpq5 libjemalloc2
82-
83-
COPY --from=app-builder /usr/local/cargo/bin/openmina-producer-dashboard /usr/local/bin/openmina-producer-dashboard
84-
COPY --from=mina-builder /go/mina/src/app/libp2p_helper/result/bin/libp2p_helper /usr/local/bin/coda-libp2p_helper
85-
COPY --from=mina-builder /go/mina/_build/default/src/app/cli/src/mina_testnet_signatures.exe /usr/local/bin/mina
94+
# hadolint ignore=DL3008
95+
RUN apt-get update && \
96+
apt-get install -y --no-install-recommends libpq5 libjemalloc2 && \
97+
rm -rf /var/lib/apt/lists/*
98+
99+
COPY --from=app-builder /usr/local/cargo/bin/openmina-producer-dashboard \
100+
/usr/local/bin/openmina-producer-dashboard
101+
COPY --from=mina-builder \
102+
/go/mina/src/app/libp2p_helper/result/bin/libp2p_helper \
103+
/usr/local/bin/coda-libp2p_helper
104+
COPY --from=mina-builder \
105+
/go/mina/_build/default/src/app/cli/src/mina_testnet_signatures.exe \
106+
/usr/local/bin/mina
86107

87108
# TODO: replace
88109
ENTRYPOINT [ "openmina-producer-dashboard" ]

frontend/Dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
FROM node:18 AS BUILD_IMAGE
2-
# Doesn't matter what we put here - it get's overwritten by the docker build command
2+
# Doesn't matter what we put here - it get's overwritten by the docker \
3+
# build command
34
ARG BUILD_CONFIGURATION=production
45
WORKDIR /app
56
COPY . .
6-
RUN npm install
7-
RUN node_modules/.bin/ng build --configuration ${BUILD_CONFIGURATION}
8-
RUN npm prune --production
9-
10-
RUN echo "---------- USING APACHE ----------"
7+
RUN npm install && \
8+
node_modules/.bin/ng build --configuration \
9+
${BUILD_CONFIGURATION} && \
10+
npm prune --production && \
11+
echo "---------- USING APACHE ----------"
1112

1213

1314
FROM httpd:2.4
1415

16+
# hadolint ignore=DL3008
1517
RUN apt-get update && \
16-
apt-get install -y curl && \
18+
apt-get install -y --no-install-recommends curl && \
1719
rm -rf /var/lib/apt/lists/*
1820

19-
COPY --from=BUILD_IMAGE /app/dist/frontend/browser /usr/local/apache2/htdocs/
20-
COPY --from=BUILD_IMAGE /app/httpd.conf /usr/local/apache2/conf/httpd.conf
21+
COPY --from=BUILD_IMAGE /app/dist/frontend/browser \
22+
/usr/local/apache2/htdocs/
23+
COPY --from=BUILD_IMAGE /app/httpd.conf \
24+
/usr/local/apache2/conf/httpd.conf
2125

2226
COPY docker/startup.sh /usr/local/bin/startup.sh
2327
RUN chmod +x /usr/local/bin/startup.sh

node/testing/docker/Dockerfile.debugger

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ FROM minaprotocol/mina-daemon:2.0.0rampup4-14047c5-focal-berkeley
55

66
COPY --from=debugger /usr/bin/bpf-recorder /usr/bin/bpf-recorder
77

8-
RUN apt-get update && apt-get -y install libelf-dev
8+
# hadolint ignore=DL3008
9+
RUN apt-get update && \
10+
apt-get -y install --no-install-recommends libelf-dev && \
11+
rm -rf /var/lib/apt/lists/*

node/testing/docker/Dockerfile.light

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
FROM golang:1.18.10-buster AS builder
22

3+
# hadolint ignore=DL3008
34
RUN apt-get update && \
4-
apt-get -y install \
5+
apt-get -y install --no-install-recommends \
56
apt-transport-https \
67
ca-certificates \
78
pkg-config \
@@ -35,7 +36,9 @@ RUN apt-get update && \
3536
rsync \
3637
liblmdb-dev
3738

38-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
39+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
40+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
41+
sh -s -- -y
3942

4043
WORKDIR /go
4144
RUN git clone https://github.com/MinaProtocol/mina.git
@@ -49,23 +52,31 @@ RUN git checkout -b 2.0.0rampup4 2.0.0rampup4 && \
4952

5053
RUN make libp2p_helper
5154

52-
RUN curl -s -L https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux -o /usr/local/bin/opam && chmod +x /usr/local/bin/opam
55+
RUN curl -s -L \
56+
https://github.com/ocaml/opam/releases/download/2.1.2/opam-2.1.2-x86_64-linux \
57+
-o /usr/local/bin/opam && \
58+
chmod +x /usr/local/bin/opam
5359

5460
RUN opam init --disable-sandboxing \
5561
&& opam switch create . \
56-
&& eval $(opam config env) \
62+
&& eval "$(opam config env)" \
5763
&& opam switch import -y opam.export \
5864
&& ./scripts/pin-external-packages.sh
5965

6066
COPY patch patch
6167

6268
RUN git apply patch
6369

64-
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
70+
SHELL ["/bin/bash", "-c"]
6571

66-
RUN source ~/.cargo/env && eval $(opam config env) && make build_all_sigs
72+
RUN source ~/.cargo/env && eval "$(opam config env)" && \
73+
make build_all_sigs
6774

6875
FROM minaprotocol/mina-daemon:2.0.0rampup4-14047c5-buster-berkeley
6976

70-
COPY --from=builder /go/mina/src/app/libp2p_helper/result/bin/libp2p_helper /usr/local/bin/coda-libp2p_helper
71-
COPY --from=builder /go/mina/_build/default/src/app/cli/src/mina_testnet_signatures.exe /usr/local/bin/mina
77+
COPY --from=builder \
78+
/go/mina/src/app/libp2p_helper/result/bin/libp2p_helper \
79+
/usr/local/bin/coda-libp2p_helper
80+
COPY --from=builder \
81+
/go/mina/_build/default/src/app/cli/src/mina_testnet_signatures.exe \
82+
/usr/local/bin/mina

0 commit comments

Comments
 (0)