From 90cd071d15f8b3bc683cb0ff41fe0bc4ccbbed03 Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Fri, 16 Oct 2020 10:12:21 -0500 Subject: [PATCH] docker --- Dockerfile | 32 ++++++++++++++++++++++++++++++++ startup_script.sh | 16 ++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Dockerfile create mode 100644 startup_script.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7a337b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM golang:1.13-alpine as builder + +RUN apk --update --no-cache add make git g++ linux-headers +# DEBUG +RUN apk add busybox-extras + +# Get and build tx_spammer +ADD . /go/src/github.com/vulcanize/tx_spammer +WORKDIR /go/src/github.com/vulcanize/tx_spammer +RUN GO111MODULE=on GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o tx_spammer . + +# app container +FROM alpine + +ARG USER="vdm" +ARG CONFIG_FILE="./environments/example.toml" + +RUN adduser -Du 5000 $USER +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 +COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/tx_spammer/$CONFIG_FILE config.toml +COPY --chown=5000:5000 --from=builder /go/src/github.com/vulcanize/tx_spammer/startup_script.sh . + +# keep binaries immutable +COPY --from=builder /go/src/github.com/vulcanize/tx_spammer/tx_spammer tx_spammer +COPY --from=builder /go/src/github.com/vulcanize/tx_spammer/environments environments + +ENTRYPOINT ["/app/startup_script.sh"] \ No newline at end of file diff --git a/startup_script.sh b/startup_script.sh new file mode 100644 index 0000000..699ca8c --- /dev/null +++ b/startup_script.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e +set +x +test $SPAMMER_COMMAND +set +e + +echo "Running tx spammer" +./ipld-eth-indexer ${SPAMMER_COMMAND} --config=config.toml --log-file=${LOG_FILE} --log-level=${LOG_LEVEL} + +if [ $? -eq 0 ]; then + echo "tx spammer ran successfully" +else + echo "tx spammer ran with error. Is the config file correct?" + exit 1 +fi \ No newline at end of file