-
Notifications
You must be signed in to change notification settings - Fork 39
/
Dockerfile.app
46 lines (31 loc) · 1.32 KB
/
Dockerfile.app
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
43
44
45
46
################################################################################
ARG GO_VERSION="1.20"
ARG BUILD_TARGET="consumer"
ARG BUILD_TYPE="debug"
################################################################################
FROM docker.io/library/golang:${GO_VERSION} AS base-consumer
WORKDIR /usr/src
COPY examples/consumer/go.mod examples/consumer/go.sum ./
RUN go mod download && go mod verify
COPY examples/consumer/ .
RUN go build -v -o /usr/local/bin/app
################################################################################
FROM docker.io/library/golang:${GO_VERSION} AS base-producer
WORKDIR /usr/src
COPY examples/producer/go.mod examples/producer/go.sum ./
RUN go mod download && go mod verify
COPY examples/producer/ .
RUN go build -v -o /usr/local/bin/app
################################################################################
FROM base-${BUILD_TARGET} AS base
FROM docker.io/library/debian:11 AS app-release
COPY --from=base /usr/local/bin/app /usr/local/bin/app
FROM base AS app-debug
RUN set -eux; \
DEBIAN_FRONTEND=noninteractive apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y -q tmux vim telnet; \
rm -rf /var/cache/apt;
################################################################################
FROM app-${BUILD_TYPE} AS app
WORKDIR /
CMD ["app"]