2023-03-17 17:51:46 +00:00
|
|
|
FROM golang:1.19-alpine as builder
|
2020-08-19 20:30:52 +00:00
|
|
|
|
2023-09-01 17:20:46 +00:00
|
|
|
RUN apk add --no-cache git gcc musl-dev binutils-gold
|
2020-08-19 20:30:52 +00:00
|
|
|
# DEBUG
|
|
|
|
RUN apk add busybox-extras
|
|
|
|
|
2023-09-01 17:20:46 +00:00
|
|
|
WORKDIR /eth-statediff-service
|
2021-10-21 19:02:22 +00:00
|
|
|
|
2023-09-01 17:20:46 +00:00
|
|
|
ARG GIT_VDBTO_TOKEN
|
|
|
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN if [ -n "$GIT_VDBTO_TOKEN" ]; then git config --global url."https://$GIT_VDBTO_TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"; fi && \
|
|
|
|
go mod download && \
|
|
|
|
rm -f ~/.gitconfig
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
RUN go build -ldflags '-extldflags "-static"' -o eth-statediff-service .
|
2020-08-19 20:30:52 +00:00
|
|
|
|
|
|
|
FROM alpine
|
|
|
|
|
2023-09-01 17:20:46 +00:00
|
|
|
ARG USER="vdbm"
|
2020-11-09 18:49:33 +00:00
|
|
|
ARG EXPOSE_PORT=8545
|
2021-10-21 19:02:22 +00:00
|
|
|
|
|
|
|
RUN adduser -Du 5000 $USER adm
|
|
|
|
RUN adduser $USER adm; apk --no-cache add sudo; echo '%adm ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
|
|
|
|
2020-08-19 20:30:52 +00:00
|
|
|
WORKDIR /app
|
|
|
|
RUN chown $USER /app
|
|
|
|
USER $USER
|
|
|
|
|
|
|
|
# chown first so dir is writable
|
|
|
|
# note: using $USER is merged, but not in the stable release yet
|
2023-09-01 17:20:46 +00:00
|
|
|
COPY --chown=5000:5000 --from=builder /eth-statediff-service/startup_script.sh .
|
|
|
|
COPY --chown=5000:5000 --from=builder /eth-statediff-service/environments environments
|
2020-08-19 20:30:52 +00:00
|
|
|
|
|
|
|
# keep binaries immutable
|
2023-09-01 17:20:46 +00:00
|
|
|
COPY --from=builder /eth-statediff-service/eth-statediff-service eth-statediff-service
|
2020-08-19 20:30:52 +00:00
|
|
|
|
|
|
|
EXPOSE $EXPOSE_PORT
|
|
|
|
|
|
|
|
ENTRYPOINT ["/app/startup_script.sh"]
|