Skip to content

Commit 141744c

Browse files
committed
update docker file for accounting service
1 parent a7b7da1 commit 141744c

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/accountingservice/Dockerfile

+25-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,30 @@ WORKDIR /usr/src/app/
88
RUN apk update \
99
&& apk add --no-cache make protobuf-dev
1010

11-
COPY ./src/accountingservice/ ./
12-
RUN go build -o /go/bin/accountingservice/
11+
WORKDIR /usr/src/app
12+
13+
RUN apk update \
14+
&& apk add --no-cache make protobuf-dev
15+
16+
COPY ./src/accountingservice/go.sum tools/go.sum
17+
COPY ./src/accountingservice/go.mod tools/go.mod
18+
COPY ./src/accountingservice/tools.go tools/tools.go
19+
20+
WORKDIR /usr/src/app/tools
21+
22+
RUN go mod download \
23+
&& go list -e -f '{{range .Imports}}{{.}} {{end}}' tools.go | CGO_ENABLED=0 xargs go install -mod=readonly
24+
25+
WORKDIR /usr/src/app/
26+
27+
COPY ./src/accountingservice ./src/accountingservice
28+
COPY ./pb ./pb
29+
30+
RUN protoc -I ./pb ./pb/demo.proto --go_out=./src/accountingservice --go-grpc_out=./src/accountingservice
31+
WORKDIR /usr/src/app/src/accountingservice
32+
RUN go build -ldflags "-s -w" -o /go/bin/accountingservice/ ./
33+
34+
1335

1436
# -----------------------------------------------------------------------------
1537

@@ -19,4 +41,4 @@ WORKDIR /usr/src/app/
1941

2042
COPY --from=builder /go/bin/accountingservice/ ./
2143

22-
ENTRYPOINT [ "./accountingservice" ]
44+
ENTRYPOINT [ "./accountingservice" ]

0 commit comments

Comments
 (0)