Skip to content

Commit

Permalink
Dockerfile: Replace alpine by debian. Use same dockerfile for amd and…
Browse files Browse the repository at this point in the history
… arm (#2192)

* Add wget package

* Using same dockerfile for amd and arm

* Delete old dockerfiles

* Using debian-slim
  • Loading branch information
jcortejoso authored Oct 24, 2023
1 parent 4e9521d commit a59dd19
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 208 deletions.
63 changes: 6 additions & 57 deletions .github/workflows/build-sign-commit-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

jobs:
build-container-geth-amd-sha:
build-container-geth-sha:
runs-on: [self-hosted, blockchain, 8-cpu]
permissions:
contents: read
Expand All @@ -25,40 +25,15 @@ jobs:
- name: Build and push container
uses: celo-org/reusable-workflows/.github/actions/build-container@9817fca8d235a679e56bdcc72c31dfc548413805
with:
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
registry: us-west1-docker.pkg.dev/devopsre/dev-images/geth
tag: ${{ github.sha }}
context: .
dockerfile: Dockerfile
push: ${{ fromJSON(true) }}
load: ${{ fromJSON(false) }}

build-container-geth-arm-sha:
runs-on: [self-hosted, blockchain, 8-cpu]
permissions:
contents: read
id-token: write
security-events: write
steps:
- uses: actions/checkout@v3
- name: Login at GCP Artifact Registry
uses: celo-org/reusable-workflows/.github/actions/auth-gcp-artifact-registry@9817fca8d235a679e56bdcc72c31dfc548413805
with:
workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-celo-blockchain-dev/providers/github-by-repos'
service-account: '[email protected]'
artifact-registry: us-west1-docker.pkg.dev/devopsre/dev-images/geth
- name: Build and push container
uses: celo-org/reusable-workflows/.github/actions/build-container@9817fca8d235a679e56bdcc72c31dfc548413805
with:
platforms: linux/arm64
registry: us-west1-docker.pkg.dev/devopsre/dev-images/geth
tag: ${{ github.sha }}
context: .
dockerfile: Dockerfile.arm64
push: ${{ fromJSON(true) }}
load: ${{ fromJSON(false) }}

build-container-geth-amd-master:
build-container-geth-master:
runs-on: [self-hosted, blockchain, 8-cpu]
if: github.ref == 'refs/heads/master'
permissions:
Expand All @@ -76,40 +51,14 @@ jobs:
- name: Build and push container
uses: celo-org/reusable-workflows/.github/actions/build-container@9817fca8d235a679e56bdcc72c31dfc548413805
with:
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
registry: us-west1-docker.pkg.dev/devopsre/dev-images/geth
tag: master
context: .
dockerfile: Dockerfile
push: ${{ fromJSON(true) }}
load: ${{ fromJSON(false) }}

build-container-geth-arm-master:
runs-on: [self-hosted, blockchain, 8-cpu]
if: github.ref == 'refs/heads/master'
permissions:
contents: read
id-token: write
security-events: write
steps:
- uses: actions/checkout@v3
- name: Login at GCP Artifact Registry
uses: celo-org/reusable-workflows/.github/actions/auth-gcp-artifact-registry@9817fca8d235a679e56bdcc72c31dfc548413805
with:
workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-celo-blockchain/providers/github-by-repos'
service-account: '[email protected]'
artifact-registry: us-west1-docker.pkg.dev/devopsre/celo-blockchain-public/geth
- name: Build and push container
uses: celo-org/reusable-workflows/.github/actions/build-container@9817fca8d235a679e56bdcc72c31dfc548413805
with:
platforms: linux/arm64
registry: us-west1-docker.pkg.dev/devopsre/dev-images/geth
tag: master
context: .
dockerfile: Dockerfile.arm64
push: ${{ fromJSON(true) }}
load: ${{ fromJSON(false) }}

build-container-geth-all-master:
runs-on: [self-hosted, blockchain, 8-cpu]
if: github.ref == 'refs/heads/master'
Expand All @@ -128,8 +77,8 @@ jobs:
- name: Build and push container
uses: celo-org/reusable-workflows/.github/actions/build-container@9817fca8d235a679e56bdcc72c31dfc548413805
with:
platforms: linux/amd64
registry: us-west1-docker.pkg.dev/devopsre/dev-images/geth
platforms: linux/amd64,linux/arm64
registry: us-west1-docker.pkg.dev/devopsre/dev-images/geth-all
tag: master
context: .
dockerfile: Dockerfile.alltools
Expand Down
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,33 @@
#
# Once you are satisfied, build the image using
# export COMMIT_SHA=$(git rev-parse HEAD)
# docker build -f Dockerfile --build-arg COMMIT_SHA=$COMMIT_SHA -t gcr.io/celo-testnet/geth:$COMMIT_SHA .
# docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile --build-arg COMMIT_SHA=$COMMIT_SHA -t gcr.io/celo-testnet/geth:$COMMIT_SHA .
#
# push the image to the cloud
# docker push gcr.io/celo-testnet/geth:$COMMIT_SHA
#
# To use this image for testing, modify GETH_NODE_DOCKER_IMAGE_TAG in celo-monorepo/.env file

# Build Geth in a stock Go builder container
FROM golang:1.19-alpine as builder
FROM golang:1.19-bookworm as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git
RUN headers_package="linux-headers-$(dpkg --print-architecture)" && \
apt update && \
apt install -y build-essential git musl-dev $headers_package

ADD . /go-ethereum
RUN cd /go-ethereum && make geth-musl

# Pull Geth into a second stage deploy alpine container
FROM alpine:latest
FROM debian:bookworm-slim
ARG COMMIT_SHA

RUN apk add --no-cache ca-certificates
RUN apt update &&\
apt install -y ca-certificates wget &&\
rm -rf /var/cache/apt &&\
rm -rf /var/lib/apt/lists/* &&\
ln -sf /bin/bash /bin/sh

COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
RUN echo $COMMIT_SHA > /version.txt
ADD scripts/run_geth_in_docker.sh /
Expand All @@ -40,3 +47,4 @@ ARG VERSION=""
ARG BUILDNUM=""

LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"

16 changes: 12 additions & 4 deletions Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# Build Geth in a stock Go builder container
FROM golang:1.19-alpine as builder
FROM golang:1.19-bookworm as builder

RUN apk add --no-cache make gcc musl-dev linux-headers git
RUN headers_package="linux-headers-$(dpkg --print-architecture)" && \
apt update && \
apt install -y build-essential git musl-dev $headers_package

ADD . /go-ethereum
RUN cd /go-ethereum && make all-musl

# Pull all binaries into a second stage deploy alpine container
FROM alpine:latest
FROM debian:bookworm
ARG COMMIT_SHA

RUN apk add --no-cache ca-certificates
RUN apt update &&\
apt install -y ca-certificates wget &&\
rm -rf /var/cache/apt &&\
rm -rf /var/lib/apt/lists/* &&\
ln -sf /bin/bash /bin/sh

COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
RUN echo $COMMIT_SHA > /version.txt

Expand All @@ -22,3 +29,4 @@ ARG VERSION=""
ARG BUILDNUM=""

LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"

111 changes: 0 additions & 111 deletions Dockerfile.android

This file was deleted.

31 changes: 0 additions & 31 deletions Dockerfile.arm64

This file was deleted.

0 comments on commit a59dd19

Please sign in to comment.