-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (37 loc) · 1.33 KB
/
Dockerfile
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
47
48
49
50
51
52
ARG GO_VERSION=1.22.0
ARG GCLOUD_SDK_VERSION=489.0.0
FROM golang:${GO_VERSION}-bullseye as builder
LABEL maintainer="dipjyotimetia"
LABEL version="3.0"
LABEL description="This is a custom image for GCP Pubsub Emulator"
LABEL repository="https://github.com/dipjyotimetia/pubsub-emulator"
ENV PUBSUB_PROJECT ${PUBSUB_PROJECT}
ENV PUBSUB_TOPIC ${PUBSUB_TOPIC}
ENV PUBSUB_SUBSCRIPTION ${PUBSUB_SUBSCRIPTION}
ENV PUBSUB_EMULATOR_HOST ${PUBSUB_PORT}
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
RUN curl -s https://raw.githubusercontent.com/eficode/wait-for/master/wait-for -o /usr/bin/wait-for
RUN chmod +x /usr/bin/wait-for
WORKDIR /build
ENV GO111MODULE=on
COPY go.mod go.sum main.go ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
RUN --mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=linux go build .
FROM google/cloud-sdk:${GCLOUD_SDK_VERSION}-emulators
COPY --from=builder /usr/bin/wait-for /usr/bin
COPY --from=builder /build/pubsub-emulator /usr/bin
COPY run.sh /run.sh
RUN apt-get update && apt-get install -y --no-install-recommends \
netcat-openbsd \
bash \
openjdk-17-jre-headless \
&& rm -rf /var/lib/apt/lists/*
EXPOSE ${PUBSUB_PORT}
RUN chmod +x /run.sh
ENTRYPOINT [ "sh", "/run.sh"]