############################ # STEP 1 build executable binary ############################ FROM golang:alpine AS builder # Install git. # Git is required for fetching the dependencies. RUN apk update && apk add --no-cache git ENV PATH=$PATH:/src/oef/ RUN mkdir -p /src/oef ADD . /src/oef COPY config/config.aws.yaml /src/oef/config/config.yaml WORKDIR /src/oef/ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o oef *.go # RUN go build -o oef *.go ############################ # STEP 2 build a small image ############################ FROM scratch # Copy our static executable. COPY --from=builder /src/oef/oef /src/oef/oef # Copy config file COPY --from=builder /src/oef/config/config.yaml /src/oef/config/config.yaml WORKDIR /src/oef/ # Run the oef binary. ENTRYPOINT ["/src/oef/oef"] EXPOSE 80 # FROM golang:latest # ENV PATH=$PATH:/src/oef/ # RUN mkdir -p /src/oef # ADD . /src/oef # COPY config/config.aws.yaml /src/oef/config/config.yaml # WORKDIR /src/oef/ # RUN go build -o oef *.go # ENTRYPOINT ["/src/oef/oef"] # EXPOSE 80