mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 19:13:52 +00:00
34 lines
918 B
Docker
34 lines
918 B
Docker
# First stage container
|
|
FROM golang:1.21-alpine3.18 AS builder
|
|
RUN apk add --no-cache git ca-certificates gcc musl-dev libc-dev pkgconfig
|
|
# gcc is for github.com/mattn/go-sqlite3
|
|
# ADD . $GOPATH/src/github.com/c9s/bbgo
|
|
|
|
|
|
WORKDIR $GOPATH/src/github.com/c9s/bbgo
|
|
ARG GO_MOD_CACHE
|
|
ENV WORKDIR=$GOPATH/src/github.com/c9s/bbgo
|
|
ENV GOPATH_ORIG=$GOPATH
|
|
ENV GOPATH=${GO_MOD_CACHE:+$WORKDIR/$GO_MOD_CACHE}
|
|
ENV GOPATH=${GOPATH:-$GOPATH_ORIG}
|
|
ENV CGO_ENABLED=1
|
|
RUN cd $WORKDIR
|
|
ADD . .
|
|
RUN go get github.com/mattn/go-sqlite3
|
|
RUN go build -o $GOPATH_ORIG/bin/bbgo ./cmd/bbgo
|
|
|
|
# Second stage container
|
|
FROM alpine:3.18
|
|
|
|
# Create the default user 'bbgo' and assign to env 'USER'
|
|
ENV USER=bbgo
|
|
RUN adduser -D -G wheel "$USER"
|
|
USER ${USER}
|
|
|
|
COPY --from=builder /go/bin/bbgo /usr/local/bin
|
|
|
|
WORKDIR /home/${USER}
|
|
ENTRYPOINT ["/usr/local/bin/bbgo"]
|
|
CMD ["run", "--config", "/config/bbgo.yaml", "--no-compile"]
|
|
# vim:filetype=dockerfile:
|