Dockerfile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ARG ALPINE_VERSION="3.12"
  16. ARG GO_VERSION
  17. FROM golang:${GO_VERSION} AS builder
  18. ARG PGBOUNCER_EXPORTER_VERSION
  19. WORKDIR /usr/src/myapp
  20. SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]
  21. RUN URL="https://github.com/jbub/pgbouncer_exporter/archive/v${PGBOUNCER_EXPORTER_VERSION}.tar.gz" \
  22. && curl -L "${URL}" | tar -zx --strip-components 1 \
  23. && PLATFORM=$([ "$(uname -m)" = "aarch64" ] && echo "arm64" || echo "amd64" )\
  24. && GOOS=linux GOARCH="${PLATFORM}" CGO_ENABLED=0 go build -v
  25. FROM alpine:${ALPINE_VERSION} AS final
  26. # We want to make sure this one includes latest security fixes.
  27. # "Pin versions in apk add" https://github.com/hadolint/hadolint/wiki/DL3018
  28. # hadolint ignore=DL3018
  29. RUN apk --no-cache add libressl libressl-dev
  30. COPY --from=builder /usr/src/myapp/pgbouncer_exporter /bin
  31. ARG PGBOUNCER_EXPORTER_VERSION
  32. ARG AIRFLOW_PGBOUNCER_EXPORTER_VERSION
  33. ARG GO_VERSION
  34. ARG COMMIT_SHA
  35. LABEL org.apache.airflow.component="pgbouncer-exporter" \
  36. org.apache.airflow.pgbouncer-exporter.version="${PGBOUNCER_EXPORTER_VERSION}" \
  37. org.apache.airflow.go.version="${GO_VERSION}" \
  38. org.apache.airflow.airflow-pgbouncer-exporter.version="${AIRFLOW_PGBOUNCER_EXPORTER_VERSION}" \
  39. org.apache.airflow.commit-sha="${COMMIT_SHA}" \
  40. maintainer="Apache Airflow Community <dev@airflow.apache.org>"
  41. HEALTHCHECK CMD ["/bin/pgbouncer_exporter", "health"]
  42. ENTRYPOINT ["/bin/pgbouncer_exporter"]
  43. CMD ["server"]