Skip to content

Commit

Permalink
[Feature] Change dockerfile to use digest (NethermindEth#3113)
Browse files Browse the repository at this point in the history
* Set docker pull by digest in Dockerfile

* Set docker pull by digest in Dockerfile.rocksdb

* Set docker pull by digest in Dockerfile.stateRunner

* Set docker pull by digest in Dockerfile.gmp

* Set docker pull by digest in Dockerfile.e2e

* Remove Dockerfile.globalization

* Set docker pull by digest in Prometheus Dockerfile

* Set docker pull by digest in Dockerfile.secp256k1

* Update dockerfile image digest

* Update Dockerfile.e2e

* Update Dockerfile.e2e to latest image

* Add readme for add digest for images

* Merge origin/master

Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
  • Loading branch information
stdevMac and LukaszRozmej authored Jul 29, 2021
1 parent 4931a59 commit 530ab44
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 42 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:5.0 AS build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk@sha256:fa19559201c43bc8191c1a095670e242de80a23697d24f5a3460019958637c63 AS build

ARG TARGETPLATFORM
ARG TARGETOS
Expand All @@ -14,7 +14,7 @@ RUN if [ "$TARGETARCH" = "amd64" ] ; \
dotnet publish src/Nethermind/Nethermind.Runner -r $TARGETOS-$TARGETARCH -c release -o out ; \
fi

FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:5.0
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet@sha256:1d75db770c7ce82b128744770271bd87dc9d119f0ef15b94cab0f84477abfaec
RUN apt-get update && apt-get -y install libsnappy-dev libc6-dev libc6

WORKDIR /nethermind
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.e2e
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build

FROM mcr.microsoft.com/dotnet/sdk@sha256:e8dce81012457ec0d87929aff8d60277c01b88fdd80bd128f1d4fc1c1bbdeb74 AS build
COPY . .
RUN git submodule update --init src/Dirichlet src/int256 src/rocksdb-sharp src/Math.Gmp.Native
RUN dotnet publish src/Nethermind/Nethermind.DataMarketplace.Consumers.Test.EndToEnd -c release -o out

FROM mcr.microsoft.com/dotnet/aspnet:5.0
FROM mcr.microsoft.com/dotnet/aspnet@sha256:df9df076ae5c0a6b88ff5a5faa4bba123b6e64fecfd5ecd19005b527309a5785
RUN apt-get update && apt-get -y install libsnappy-dev libc6-dev libc6 unzip
WORKDIR /e2e
COPY --from=build /out .
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.gmp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:10 AS gmp
FROM debian@sha256:acf7795dc91df17e10effee064bd229580a9c34213b4dba578d64768af5d8c51 AS gmp
WORKDIR /source

RUN apt-get update && apt-get install -y mercurial autoconf automake libtool texinfo build-essential bison
Expand All @@ -12,6 +12,6 @@ RUN hg clone https://gmplib.org/repo/gmp-6.2/ gmp && \
RUN strip gmp/.libs/libgmp.so


FROM debian:10 AS libgmp
FROM debian@sha256:acf7795dc91df17e10effee064bd229580a9c34213b4dba578d64768af5d8c51 AS libgmp
WORKDIR /nethermind
COPY --from=gmp /source/gmp/.libs/libgmp.so .
COPY --from=gmp /source/gmp/.libs/libgmp.so .
4 changes: 2 additions & 2 deletions Dockerfile.rocksdb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:10 AS rocksdb
FROM debian@sha256:acf7795dc91df17e10effee064bd229580a9c34213b4dba578d64768af5d8c51 AS rocksdb
WORKDIR /source

ARG TARGETPLATFORM
Expand All @@ -10,6 +10,6 @@ RUN PORTABLE=1 make -j16 shared_lib

RUN strip librocksdb.so

FROM debian:10 AS librocksdb
FROM debian@sha256:acf7795dc91df17e10effee064bd229580a9c34213b4dba578d64768af5d8c51 AS librocksdb
WORKDIR /nethermind
COPY --from=rocksdb /source/librocksdb.so .
6 changes: 3 additions & 3 deletions Dockerfile.secp256k1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:10 AS secp256k1
FROM debian@sha256:acf7795dc91df17e10effee064bd229580a9c34213b4dba578d64768af5d8c51 AS secp256k1
WORKDIR /source

RUN apt-get update && apt-get install -y git autoconf automake libtool build-essential
Expand All @@ -11,6 +11,6 @@ RUN git clone https://github.com/NethermindEth/secp256k1 . && \
RUN strip .libs/libsecp256k1.so


FROM debian:10 AS libsecp256k1
FROM debian@sha256:acf7795dc91df17e10effee064bd229580a9c34213b4dba578d64768af5d8c51 AS libsecp256k1
WORKDIR /nethermind
COPY --from=secp256k1 /source/.libs/libsecp256k1.so .
COPY --from=secp256k1 /source/.libs/libsecp256k1.so .
4 changes: 2 additions & 2 deletions Dockerfile.stateRunner
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk@sha256:6edc3ea5eb689712b9ec6ad5777e32c5bfa51db94a3e5fb069278ccf3b74b7c1 AS build

COPY . .

RUN apk add git && \
git submodule update --init src/Dirichlet src/int256 src/Math.Gmp.Native && \
dotnet publish src/Nethermind/Nethermind.State.Test.Runner -c release -o out

FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine
FROM mcr.microsoft.com/dotnet/sdk@sha256:6edc3ea5eb689712b9ec6ad5777e32c5bfa51db94a3e5fb069278ccf3b74b7c1

COPY --from=build /out .

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ dotnet run -c Release --no-build -- --config mainnet

Official Nethermind docker images are available on [Docker Hub](https://hub.docker.com/r/nethermind/nethermind).

### Get digest of docker image

In case of any docker image need to be updated in the repository, you can update the digest of this images with the next commands

```sh
docker inspect --format='{{index .RepoDigests 0}}' <image_name>
```

The output must show the image digest, and then you can copy that output in the `FROM` tag inside the Dockerfile

## Test

If you want to run the Nethermind or Ethereum Foundation tests, then:
Expand Down
25 changes: 0 additions & 25 deletions src/Dockerfile.globalization

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM prom/prometheus
FROM prom/prometheus@sha256:5accb68b56ba452e449a5e552411acaeabbbe0f087acf19a1157ce3dd10a8bed
WORKDIR /app
COPY ./prometheus.yml /etc/prometheus/prometheus.yml
COPY ./prometheus.yml /etc/prometheus/prometheus.yml
2 changes: 1 addition & 1 deletion src/tests
Submodule tests updated from 5d534e to 4d539d

0 comments on commit 530ab44

Please sign in to comment.