-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.debug
42 lines (28 loc) · 914 Bytes
/
Dockerfile.debug
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
FROM golang:1.14-alpine AS build-env
ENV CGO_ENABLED 0
# Allow Go to retreive the dependencies for the build step
RUN apk add --no-cache git
# Move to working directory /build
WORKDIR /build
# Copy and download dependency using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy the code into the container
COPY . .
# Build the application
RUN go build -gcflags "all=-N -l" -o main ./cmd/api
# Move to /dist directory as the place for resulting binary folder
WORKDIR /dist
# Copy binary from build to main folder
RUN cp /build/main .
# Get Delve from a GOPATH not from a Go Modules project
WORKDIR /go/src/
RUN go get github.com/go-delve/delve/cmd/dlv
# final stage
FROM alpine:3.8
WORKDIR /
COPY --from=build-env /dist/main /
COPY --from=build-env /go/bin/dlv /
EXPOSE 3000 2345
CMD ["/dlv", "--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/main"]