bsc/Dockerfile
dylanhuang 282ef8952d
ci: fix release job (#1519)
* ci: remove CGO_ENABLE=0 due to blst package
* ci: fix arm binary build
* ci: remove arm5-7 version
* ci: fix arm64 build script
* ci: fix generate_change_log.sh
2023-04-24 22:30:27 +08:00

62 lines
1.7 KiB
Docker

# Support setting various labels on the final image
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""
# Build Geth in a stock Go builder container
FROM golang:1.19-alpine as builder
RUN apk add --no-cache make cmake gcc musl-dev linux-headers git bash build-base libc-dev
# Get dependencies - will also be cached if we won't change go.mod/go.sum
COPY go.mod /go-ethereum/
COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download
ADD . /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth
# Pull Geth into a second stage deploy alpine container
FROM alpine:3.17
ARG BSC_USER=bsc
ARG BSC_USER_UID=1000
ARG BSC_USER_GID=1000
ENV BSC_HOME=/bsc
ENV HOME=${BSC_HOME}
ENV DATA_DIR=/data
ENV PACKAGES ca-certificates jq \
bash bind-tools tini \
grep curl sed gcc
RUN apk add --no-cache $PACKAGES \
&& rm -rf /var/cache/apk/* \
&& addgroup -g ${BSC_USER_GID} ${BSC_USER} \
&& adduser -u ${BSC_USER_UID} -G ${BSC_USER} --shell /sbin/nologin --no-create-home -D ${BSC_USER} \
&& addgroup ${BSC_USER} tty \
&& sed -i -e "s/bin\/sh/bin\/bash/" /etc/passwd
RUN echo "[ ! -z \"\$TERM\" -a -r /etc/motd ] && cat /etc/motd" >> /etc/bash/bashrc
WORKDIR ${BSC_HOME}
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
COPY docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh \
&& mkdir -p ${DATA_DIR} \
&& chown -R ${BSC_USER_UID}:${BSC_USER_GID} ${BSC_HOME} ${DATA_DIR}
VOLUME ${DATA_DIR}
USER ${BSC_USER_UID}:${BSC_USER_GID}
# rpc ws graphql
EXPOSE 8545 8546 8547 30303 30303/udp
# For blst runtime env
ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__"
ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__"
ENTRYPOINT ["/sbin/tini", "--", "./docker-entrypoint.sh"]