2020-12-14 06:06:02 +00:00
|
|
|
# First stage container
|
2023-02-24 18:56:08 +00:00
|
|
|
FROM golang:1.18.10-alpine3.17 AS builder
|
2020-12-14 06:06:02 +00:00
|
|
|
RUN apk add --no-cache git ca-certificates gcc libc-dev pkgconfig
|
|
|
|
# gcc is for github.com/mattn/go-sqlite3
|
2020-12-17 08:19:31 +00:00
|
|
|
# ADD . $GOPATH/src/github.com/c9s/bbgo
|
|
|
|
|
2020-12-14 06:06:02 +00:00
|
|
|
WORKDIR $GOPATH/src/github.com/c9s/bbgo
|
2020-12-17 06:44:19 +00:00
|
|
|
ARG GO_MOD_CACHE
|
2020-12-17 08:19:31 +00:00
|
|
|
ENV WORKDIR=$GOPATH/src/github.com/c9s/bbgo
|
2020-12-17 06:44:19 +00:00
|
|
|
ENV GOPATH_ORIG=$GOPATH
|
2020-12-17 08:19:31 +00:00
|
|
|
ENV GOPATH=${GO_MOD_CACHE:+$WORKDIR/$GO_MOD_CACHE}
|
2020-12-17 06:44:19 +00:00
|
|
|
ENV GOPATH=${GOPATH:-$GOPATH_ORIG}
|
2021-12-27 10:22:54 +00:00
|
|
|
ENV CGO_ENABLED=1
|
2022-05-17 03:30:36 +00:00
|
|
|
RUN cd $WORKDIR && go get github.com/mattn/go-sqlite3
|
2020-12-17 08:19:31 +00:00
|
|
|
ADD . .
|
2020-12-17 06:44:19 +00:00
|
|
|
RUN go build -o $GOPATH_ORIG/bin/bbgo ./cmd/bbgo
|
2020-12-14 06:06:02 +00:00
|
|
|
|
|
|
|
# Second stage container
|
2023-02-24 18:56:08 +00:00
|
|
|
FROM alpine:3.17
|
2020-12-14 06:06:02 +00:00
|
|
|
|
2022-06-22 08:45:23 +00:00
|
|
|
# Create the default user 'bbgo' and assign to env 'USER'
|
|
|
|
ENV USER=bbgo
|
|
|
|
RUN adduser -D -G wheel "$USER"
|
|
|
|
USER ${USER}
|
2020-12-14 06:06:02 +00:00
|
|
|
|
|
|
|
COPY --from=builder /go/bin/bbgo /usr/local/bin
|
|
|
|
|
2022-06-22 08:45:23 +00:00
|
|
|
WORKDIR /home/${USER}
|
2020-12-14 06:06:02 +00:00
|
|
|
ENTRYPOINT ["/usr/local/bin/bbgo"]
|
2020-12-15 10:57:46 +00:00
|
|
|
CMD ["run", "--config", "/config/bbgo.yaml", "--no-compile"]
|
2020-12-14 06:06:02 +00:00
|
|
|
# vim:filetype=dockerfile:
|