Skip to content

Commit

Permalink
Use variable for exposed ports and move important ARGs before first F…
Browse files Browse the repository at this point in the history
…ROM (#11851)
  • Loading branch information
lystopad authored Sep 3, 2024
1 parent b7c02f3 commit 82ca4da
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
ARG RELEASE_DOCKER_BASE_IMAGE="alpine:3.20.1"
ARG RELEASE_DOCKER_BASE_IMAGE="alpine:3.20.1" \
CI_CD_MAIN_BUILDER_IMAGE="golang:1.22-bookworm" \
CI_CD_MAIN_TARGET_BASE_IMAGE="alpine:3.20.1" \
EXPOSED_PORTS="8545 \
8551 \
8546 \
30303 \
30303/udp \
42069 \
42069/udp \
8080 \
9090 \
6060"

## Note TARGETARCH is a crucial variable:
## see https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
Expand All @@ -17,7 +29,8 @@ FROM ${RELEASE_DOCKER_BASE_IMAGE} AS release

ARG USER=erigon \
GROUP=erigon \
APPLICATION
APPLICATION \
EXPOSED_PORTS

RUN --mount=type=bind,from=temporary,source=/tmp/${APPLICATION},target=/tmp/${APPLICATION} \
apk add --no-cache ca-certificates tzdata && \
Expand All @@ -37,29 +50,18 @@ WORKDIR /home/${USER}

USER ${USER}

EXPOSE 8545 \
8551 \
8546 \
30303 \
30303/udp \
42069 \
42069/udp \
8080 \
9090 \
6060
EXPOSE ${EXPOSED_PORTS}

ENTRYPOINT [ "/usr/local/bin/erigon" ]

### End of Release Dockerfile


ARG CI_CD_MAIN_BUILDER_IMAGE="golang:1.22-bookworm" \
CI_CD_MAIN_TARGET_BASE_IMAGE="alpine:3.20.1"

### CI-CD : main branch docker image publishing for each new commit id
FROM ${CI_CD_MAIN_BUILDER_IMAGE} AS builder
FROM ${CI_CD_MAIN_BUILDER_IMAGE} AS cd-cd-builder

ARG TARGETOS TARGETARCH
ARG TARGETOS \
TARGETARCH

ENV GOOS=$TARGETOS \
GOARCH=$TARGETARCH
Expand All @@ -72,13 +74,16 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
apk update && \
apk add make git gcc libstdc++ build-base linux-headers bash ca-certificates && \
make BUILD_TAGS=nosqlite,noboltdb,nosilkworm erigon integration rpcdaemon
make BUILD_TAGS=nosqlite,noboltdb,nosilkworm erigon integration rpcdaemon && \
echo "DEBUG: list of binaries:" && \
ls -lao build/bin/

FROM ${CI_CD_MAIN_TARGET_BASE_IMAGE} AS ci-cd-main-branch
ARG USER=erigon \
GROUP=erigon
GROUP=erigon \
EXPOSED_PORTS

RUN --mount=type=bind,from=builder,source=/home/erigon,target=/tmp/erigon \
RUN --mount=type=bind,from=cd-cd-builder,source=/home/erigon,target=/tmp/erigon \
apk add --no-cache ca-certificates tzdata libstdc++ && \
addgroup ${GROUP} && \
adduser -D -h /home/${USER} -G ${GROUP} ${USER} && \
Expand All @@ -89,16 +94,7 @@ VOLUME [ "/home/${USER}" ]
WORKDIR /home/${USER}

USER ${USER}
EXPOSE 8545 \
8551 \
8546 \
30303 \
30303/udp \
42069 \
42069/udp \
8080 \
9090 \
6060
EXPOSE ${EXPOSED_PORTS}

ENTRYPOINT [ "/usr/local/bin/erigon" ]

Expand Down

0 comments on commit 82ca4da

Please sign in to comment.