-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
58 lines (43 loc) · 1.7 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
FROM golang:1.20-alpine as builder
# Set up apk dependencies
ENV PACKAGES make git libc-dev bash gcc linux-headers eudev-dev curl ca-certificates build-base
# Set working directory for the build
WORKDIR /opt/app
# Add source files
COPY . .
# Install minimum necessary dependencies, remove packages
RUN apk add --no-cache $PACKAGES
# For Private REPO
ARG GH_TOKEN=""
RUN go env -w GOPRIVATE="github.com/bnb-chain/*"
RUN git config --global url."https://${GH_TOKEN}@github.com".insteadOf "https://github.com"
RUN make build
# Pull binary into a second stage deploy alpine container
FROM alpine:3.17
ARG USER=app
ARG USER_UID=1000
ARG USER_GID=1000
ENV GREENFIELD_RELAYER_HOME /opt/app
ENV CONFIG_FILE_PATH $GREENFIELD_RELAYER_HOME/config/config.json
ENV CONFIG_TYPE "local"
ENV PRIVATE_KEY ""
ENV BLS_PRIVATE_KEY ""
ENV DB_PASS ""
# You need to specify aws s3 config if you want to load config from s3
ENV AWS_REGION ""
ENV AWS_SECRET_KEY ""
ENV PACKAGES ca-certificates libstdc++
ENV WORKDIR=/app
RUN apk add --no-cache $PACKAGES \
&& rm -rf /var/cache/apk/* \
&& addgroup -g ${USER_GID} ${USER} \
&& adduser -u ${USER_UID} -G ${USER} --shell /sbin/nologin --no-create-home -D ${USER} \
&& addgroup ${USER} tty \
&& sed -i -e "s/bin\/sh/bin\/bash/" /etc/passwd
WORKDIR ${WORKDIR}
COPY --from=builder /opt/app/build/greenfield-relayer ${WORKDIR}/
RUN chown -R ${USER_UID}:${USER_GID} ${WORKDIR}
USER ${USER_UID}:${USER_GID}
VOLUME [ $GREENFIELD_RELAYER_HOME ]
# Run the app
CMD /app/greenfield-relayer --config-type "$CONFIG_TYPE" --config-path "$CONFIG_FILE_PATH" --private-key "$PRIVATE_KEY" --bls-private-key "$BLS_PRIVATE_KEY" --db-pass "$DB_PASS" --aws-region "$AWS_REGION" --aws-secret-key "$AWS_SECRET_KEY"