-
Notifications
You must be signed in to change notification settings - Fork 0
/
mqtt-forwarder.scratch.Dockerfile
41 lines (40 loc) · 2.11 KB
/
mqtt-forwarder.scratch.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
# docker build --no-cache --progress=plain --build-arg GO_VERSION=1.23 --build-arg VERSION=1.1.1 -t tobi312/tools:mqtt-forwarder -f mqtt-forwarder.scratch.Dockerfile .
ARG GO_VERSION=1.23
FROM golang:${GO_VERSION}-alpine AS builder
ARG VERSION=1.1.1
ENV GOPATH=/go
ENV CGO_ENABLED=0
RUN \
#apk update ; \
apk add --no-cache git binutils ; \
git clone --branch ${VERSION} --single-branch https://git.ypbind.de/repository/mqtt-forwarder.git ${GOPATH}/src/mqtt-forwarder ; \
#wget -qO- https://git.ypbind.de/cgit/mqtt-forwarder/snapshot/mqtt-forwarder-${VERSION}.tar.gz | tar xzv ; mv mqtt-forwarder-${VERSION} ${GOPATH}/src/mqtt-forwarder ; \
cd ${GOPATH}/src/mqtt-forwarder/src/mqtt-forwarder ; \
# create go.mod, go.sum and then build
go mod init mqtt-forwarder ; \
go mod tidy ; \
go build -o ${GOPATH}/bin/mqtt-forwarder . ; \
${GOPATH}/bin/mqtt-forwarder --version
#FROM alpine:latest
FROM scratch
ARG VCS_REF
ARG BUILD_DATE
ARG VERSION
LABEL org.opencontainers.image.title="mqtt-forwarder" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.description="Simple MQTT message forwarder to forward messages from one MQTT broker to another MQTT broker" \
org.opencontainers.image.documentation="https://ypbind.de/maus/projects/mqtt-forwarder/index.html" \
org.opencontainers.image.base.name="scratch" \
org.opencontainers.image.licenses="GPL-3.0" \
org.opencontainers.image.url="https://github.com/Tob1as/docker-tools" \
org.opencontainers.image.source="https://git.ypbind.de/cgit/mqtt-forwarder/"
#RUN apk add --no-cache ca-certificates
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder --chown=1000:1000 /go/bin/mqtt-forwarder /usr/local/bin/mqtt-forwarder
COPY --from=builder --chown=1000:1000 /go/src/mqtt-forwarder/example/config.ini /etc/mqtt-forwarder/config.ini
USER 1000:1000
ENTRYPOINT ["mqtt-forwarder"]
#CMD ["--help"]
CMD ["--config=/etc/mqtt-forwarder/config.ini"]