Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Dudi Dolev committed Jan 22, 2025
1 parent 2be9563 commit 04823da
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 9 deletions.
89 changes: 82 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,84 @@
FROM alpine AS builder
RUN apk add --no-cache ca-certificates
# #FROM alpine AS builder
# FROM docker.io/bitnami/minideb:bookworm
# #RUN apk add --no-cache ca-certificates
# RUN install_packages ca-certificates curl procps

# RUN apt-get autoremove --purge -y curl && \
# apt-get update && apt-get upgrade -y && \
# apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives

# #FROM scratch AS final
# USER 1001:1001
# #COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# COPY ./mongodb_exporter /bin/mongodb_exporter
# #RUN chmod g+rwX /bin/mongodb_exporter
# RUN chmod 777 /bin/mongodb_exporter

# EXPOSE 9216
# ENTRYPOINT ["/mongodb_exporter"]



# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0

FROM docker.io/bitnami/minideb:bookworm

ARG DOWNLOADS_URL="downloads.bitnami.com/files/stacksmith"
ARG TARGETARCH

LABEL com.vmware.cp.artifact.flavor="sha256:c50c90cfd9d12b445b011e6ad529f1ad3daea45c26d20b00732fae3cd71f6a83" \
org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \
org.opencontainers.image.created="2025-01-17T03:23:22Z" \
org.opencontainers.image.description="Application packaged by Broadcom, Inc." \
org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/mongodb-exporter/README.md" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.ref.name="0.43.1-debian-12-r2" \
org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/mongodb-exporter" \
org.opencontainers.image.title="mongodb-exporter" \
org.opencontainers.image.vendor="Broadcom, Inc." \
org.opencontainers.image.version="0.43.1"

ENV HOME="/" \
OS_ARCH="${TARGETARCH:-amd64}" \
OS_FLAVOUR="debian-12" \
OS_NAME="linux"

# COPY prebuildfs /
# SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"]
# Install required system packages and dependencies
RUN install_packages ca-certificates curl procps
# RUN mkdir -p /tmp/bitnami/pkg/cache/ ; cd /tmp/bitnami/pkg/cache/ ; \
# COMPONENTS=( \
# "mongodb-exporter-0.43.1-1-linux-${OS_ARCH}-debian-12" \
# ) ; \
# for COMPONENT in "${COMPONENTS[@]}"; do \
# if [ ! -f "${COMPONENT}.tar.gz" ]; then \
# curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz" -O ; \
# curl -SsLf "https://${DOWNLOADS_URL}/${COMPONENT}.tar.gz.sha256" -O ; \
# fi ; \
# sha256sum -c "${COMPONENT}.tar.gz.sha256" ; \
# tar -zxf "${COMPONENT}.tar.gz" -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' ; \
# rm -rf "${COMPONENT}".tar.gz{,.sha256} ; \
# done

RUN mkdir -p /opt/bitnami/mongodb-exporter/bin

COPY ./mongodb_exporter /opt/bitnami/mongodb-exporter/bin/mongodb_exporter

RUN apt-get autoremove --purge -y curl && \
apt-get update && apt-get upgrade -y && \
apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives
RUN chmod g+rwX /opt/bitnami
RUN find / -perm /6000 -type f -exec chmod a-s {} \; || true
RUN ln -sf /opt/bitnami/mongodb-exporter/bin/mongodb_exporter /bin/mongodb_exporter

ENV APP_VERSION="0.43.1" \
BITNAMI_APP_NAME="mongodb-exporter" \
PATH="/opt/bitnami/mongodb-exporter/bin:$PATH"

FROM scratch AS final
USER 65535:65535
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY ./mongodb_exporter /
EXPOSE 9216
ENTRYPOINT ["/mongodb_exporter"]

WORKDIR /opt/bitnami/mongodb-exporter
USER 1001
ENTRYPOINT [ "mongodb_exporter" ]
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ GO_TEST_PATH ?= ./...
GO_TEST_EXTRA ?=
GO_TEST_COVER_PROFILE ?= cover.out
GO_TEST_CODECOV ?=
GOARCH = amd64
CGO_ENABLED = 0
GOOS = linux

BUILD ?= $(shell date +%FT%T%z)
GOVERSION ?= $(shell go version | cut -d " " -f3)
Expand Down Expand Up @@ -68,10 +71,10 @@ env:
@echo $(TEST_ENV) | tr ' ' '\n' >.env

init: ## Install linters.
cd tools && go generate -x -tags=tools
cd tools && GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go generate -x -tags=tools

build: ## Compile using plain go build
go build -ldflags="$(GO_BUILD_LDFLAGS)" -o $(PMM_RELEASE_PATH)/mongodb_exporter
GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -ldflags="$(GO_BUILD_LDFLAGS)" -o $(PMM_RELEASE_PATH)/mongodb_exporter

release: ## Build the binaries using goreleaser
docker run --rm --privileged \
Expand Down

0 comments on commit 04823da

Please sign in to comment.