dockerfile update
This commit is contained in:
parent
5bb3e7781a
commit
1441b942a9
1 changed files with 30 additions and 7 deletions
37
Dockerfile
37
Dockerfile
|
@ -1,7 +1,30 @@
|
||||||
FROM golang:latest
|
############################
|
||||||
RUN mkdir -p /app
|
# STEP 1 build executable binary
|
||||||
WORKDIR /app
|
############################
|
||||||
ADD main.go /app
|
FROM golang:alpine AS builder
|
||||||
RUN go get -u
|
|
||||||
RUN go build ./main.go
|
# Install git.
|
||||||
CMD ["./main"]
|
# Git is required for fetching the dependencies.
|
||||||
|
RUN apk update && apk add --no-cache git
|
||||||
|
|
||||||
|
WORKDIR $GOPATH/src/git.cliffbreak.de/Cliffbreak/tsviewer
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Fetch dependencies.
|
||||||
|
|
||||||
|
# Using go get.
|
||||||
|
RUN go get -d -v
|
||||||
|
|
||||||
|
# Build the binary.
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/main
|
||||||
|
|
||||||
|
############################
|
||||||
|
# STEP 2 build a small image
|
||||||
|
############################
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
# Copy our static executable.
|
||||||
|
COPY --from=builder /go/bin/main /go/bin/main
|
||||||
|
|
||||||
|
# Run the hello binary.
|
||||||
|
ENTRYPOINT ["/go/bin/main"]
|
Loading…
Reference in a new issue