diff --git a/mqtt-forwarder.scratch.Dockerfile b/mqtt-forwarder.scratch.Dockerfile index ed690d8..91f58d5 100644 --- a/mqtt-forwarder.scratch.Dockerfile +++ b/mqtt-forwarder.scratch.Dockerfile @@ -1,16 +1,19 @@ # docker build --no-cache --progress=plain -t tobi312/tools:mqtt-forwarder -f mqtt-forwarder.scratch.Dockerfile . -FROM golang:alpine AS builder -SHELL ["/bin/ash", "-euxo", "pipefail", "-c"] -ARG VERSION=master -WORKDIR /app -RUN apk update ; \ +FROM golang:1.23-alpine AS builder +ARG VERSION=1.1.1 +ENV GOPATH=/go +ENV CGO_ENABLED=0 +RUN \ + #apk update ; \ apk add --no-cache git make binutils ; \ - git clone --branch ${VERSION} --single-branch https://git.ypbind.de/repository/mqtt-forwarder.git -WORKDIR /app/mqtt-forwarder/src/mqtt-forwarder -# create go.mod, go.sum and then build -RUN go mod init mqtt-forwarder ; \ + 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 ../../bin/mqtt-forwarder . + go build -o ${GOPATH}/bin/mqtt-forwarder . ; \ + ${GOPATH}/bin/mqtt-forwarder --version #FROM alpine:latest FROM scratch @@ -22,15 +25,15 @@ LABEL org.opencontainers.image.title="mqtt-forwarder" \ 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="" \ + 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 /app/mqtt-forwarder/bin/mqtt-forwarder /usr/local/bin/mqtt-forwarder -COPY --from=builder --chown=1000:1000 /app/mqtt-forwarder/example/config.ini /etc/mqtt-forwarder/config.ini +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"]