Skip to content

Commit 9e37d1b

Browse files
committed
TASK: optimize container build process
1 parent f991c82 commit 9e37d1b

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
FROM golang:alpine AS build-env
44
ENV GOPATH=/gopath
55
ENV PATH=$GOPATH/bin:$PATH
6-
ADD . /gopath/src/github.com/dfeyer/flow-debugproxy
6+
WORKDIR /app
77
RUN apk update && \
88
apk upgrade && \
99
apk add git
10-
RUN cd /gopath/src/github.com/dfeyer/flow-debugproxy \
11-
&& go get \
12-
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o flow-debugproxy
10+
ADD go.mod .
11+
ADD go.sum .
12+
RUN go mod download
13+
ADD . .
14+
RUN CGO_ENABLED=0 go build -o flow-debugproxy
1315

1416
#
1517
# Build step
1618
FROM alpine
1719
WORKDIR /app
1820

19-
COPY --from=build-env /gopath/src/github.com/dfeyer/flow-debugproxy/flow-debugproxy /app/
21+
COPY --from=build-env /app/flow-debugproxy /app/
2022

2123
ENV ADDITIONAL_ARGS ""
2224

0 commit comments

Comments
 (0)