Skip to content

Instantly share code, notes, and snippets.

@ZCube
Last active December 24, 2022 11:43
Show Gist options
  • Save ZCube/7e3045b1f15b1c1223f58267fc738e57 to your computer and use it in GitHub Desktop.
Save ZCube/7e3045b1f15b1c1223f58267fc738e57 to your computer and use it in GitHub Desktop.
Some examples for bitnami-compat (original Dockerfile from https://github.com/bitnami/containers)
FROM golang:1.19-bullseye AS golang-builder
RUN mkdir -p /opt/bitnami
ADD packages.sh /packages.sh
RUN chmod +x /packages.sh && \
/packages.sh
FROM mikefarah/yq:4.30.5 AS yq
FROM docker.io/bitnami/minideb:bullseye
ARG TARGETARCH
LABEL org.opencontainers.image.authors="https://github.com/ZCube/bitnami-compat" \
org.opencontainers.image.description="Application repackaged by ZCube for arm64 compatible, originaly Bitnami" \
org.opencontainers.image.ref.name="6.0.3-debian-11-r44" \
org.opencontainers.image.source="https://github.com/ZCube/bitnami-compat" \
org.opencontainers.image.title="mongodb" \
org.opencontainers.image.vendor="ZCube" \
org.opencontainers.image.version="6.0.3"
ENV HOME="/" \
OS_ARCH="${TARGETARCH:-amd64}" \
OS_FLAVOUR="debian-11" \
OS_NAME="linux"
COPY prebuildfs /
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Install required system packages and dependencies
RUN install_packages ca-certificates curl libbrotli1 libcom-err2 libcurl4 libffi7 libgcc-s1 libgcrypt20 libgmp10 libgnutls30 libgpg-error0 libgssapi-krb5-2 libhogweed6 libidn2-0 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 libldap-2.4-2 liblzma5 libnettle8 libnghttp2-14 libp11-kit0 libpsl5 librtmp1 libsasl2-2 libssh2-1 libssl1.1 libtasn1-6 libunistring2 numactl procps zlib1g
RUN echo install global
COPY --from=golang-builder /opt/bitnami/ /opt/bitnami/
# refer : https://github.com/docker-library/mongo
# license : Apache-2.0 License
# https://github.com/docker-library/mongo/blob/master/LICENSE
RUN install_packages gnupg
ARG GPG_KEYS=39BD841E4BE5FB195A65400E6A26B1AE64C3C388
RUN set -ex; \
export GNUPGHOME="$(mktemp -d)"; \
for key in $GPG_KEYS; do \
gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$key"; \
done; \
gpg --batch --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg; \
command -v gpgconf > /dev/null && gpgconf --kill all || :; \
rm -fr "$GNUPGHOME"; \
apt-key list
# Allow build-time overrides (eg. to build image with MongoDB Enterprise version)
# Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise
# Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com
# Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com .
ARG MONGO_PACKAGE=mongodb-org
ARG MONGO_REPO=repo.mongodb.org
ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO}
ENV MONGO_MAJOR 6.0
RUN echo "deb [ signed-by=/etc/apt/trusted.gpg.d/mongodb.gpg ] http://$MONGO_REPO/apt/ubuntu focal/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR multiverse" | tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list"
# http://docs.mongodb.org/master/release-notes/4.2/
ENV MONGO_VERSION 6.0.3
# 01/04/2022, https://github.com/mongodb/mongo/tree/f65ce5e25c0b26a00d091a4d24eec1a8b3a4c016
RUN set -x \
# installing "mongodb-enterprise" pulls in "tzdata" which prompts for input
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
# starting with MongoDB 4.3 (and backported to 4.0 and 4.2 *and* 3.6??), the postinst for server includes an unconditional "systemctl daemon-reload" (and we don't have anything for "systemctl" to talk to leading to dbus errors and failed package installs)
&& ln -s /bin/true /usr/local/bin/systemctl \
&& apt-get install -y \
${MONGO_PACKAGE}=$MONGO_VERSION \
${MONGO_PACKAGE}-server=$MONGO_VERSION \
${MONGO_PACKAGE}-shell=$MONGO_VERSION \
${MONGO_PACKAGE}-mongos=$MONGO_VERSION \
${MONGO_PACKAGE}-tools=$MONGO_VERSION \
mongodb-mongosh \
&& rm -f /usr/local/bin/systemctl \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/mongodb \
&& mv /etc/mongod.conf /etc/mongod.conf.orig
RUN mkdir -p /opt/bitnami/mongodb/bin \
&& ln -s /usr/bin/install_compass /opt/bitnami/mongodb/bin/ \
&& ln -s /usr/bin/bsondump /opt/bitnami/mongodb/bin/ \
&& ln -s /usr/bin/mongo* /opt/bitnami/mongodb/bin/ \
&& rm -rf /etc/mysql/mongodb.cnf \
&& chown 1001:1001 -R /opt/bitnami/mongodb
# mongodb-shell in mongodb
ADD https://raw.githubusercontent.com/mikefarah/yq/master/LICENSE /opt/bitnami/common/licenses/LICENSE
COPY --from=yq /usr/bin/yq /opt/bitnami/common/bin/
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
COPY rootfs /
RUN /opt/bitnami/scripts/mongodb/postunpack.sh
ENV APP_VERSION="6.0.3" \
BITNAMI_APP_NAME="mongodb" \
PATH="/opt/bitnami/mongodb/bin:/opt/bitnami/common/bin:$PATH"
EXPOSE 27017
USER 1001
ENTRYPOINT [ "/opt/bitnami/scripts/mongodb/entrypoint.sh" ]
CMD [ "/opt/bitnami/scripts/mongodb/run.sh" ]
#!/bin/bash
set -e
export PACKAGE=gosu
export TARGET_DIR=common
export VERSION=1.14.0
export REF=1.14
export CGO_ENABLED=0
rm -rf ${PACKAGE} || true
mkdir -p ${PACKAGE}
git clone -b "${REF}" https://github.com/tianon/gosu ${PACKAGE}
pushd ${PACKAGE}
go mod download
go build -v -ldflags '-d -s -w' .
mkdir -p /opt/bitnami/${TARGET_DIR}/licenses
mkdir -p /opt/bitnami/${TARGET_DIR}/bin
cp -f LICENSE /opt/bitnami/${TARGET_DIR}/licenses/${PACKAGE}-${VERSION}.txt
cp -f ${PACKAGE} /opt/bitnami/${TARGET_DIR}/bin/gosu
popd
rm -rf ${PACKAGE}
#!/bin/bash
set -e
export PACKAGE=render-template
export TARGET_DIR=common
export VERSION=1.0.4
export REF=v${VERSION}
export CGO_ENABLED=0
rm -rf ${PACKAGE} || true
mkdir -p ${PACKAGE}
git clone -b "${REF}" https://github.com/bitnami/render-template ${PACKAGE}
pushd ${PACKAGE}
go mod download
go build -v -ldflags '-d -s -w' .
mkdir -p /opt/bitnami/${TARGET_DIR}/licenses
mkdir -p /opt/bitnami/${TARGET_DIR}/bin
cp -f COPYING /opt/bitnami/${TARGET_DIR}/licenses/${PACKAGE}-${VERSION}.txt
cp -f ${PACKAGE} /opt/bitnami/${TARGET_DIR}/bin/${PACKAGE}
popd
rm -rf ${PACKAGE}
#!/bin/bash
set -e
export PACKAGE=wait-for-port
export TARGET_DIR=common
export VERSION=1.0.5
export REF=v${VERSION}
export CGO_ENABLED=0
rm -rf ${PACKAGE} || true
mkdir -p ${PACKAGE}
git clone -b "${REF}" https://github.com/bitnami/wait-for-port ${PACKAGE}
pushd ${PACKAGE}
go mod download
go build -v -ldflags '-d -s -w' .
mkdir -p /opt/bitnami/${TARGET_DIR}/licenses
mkdir -p /opt/bitnami/${TARGET_DIR}/bin
cp -f COPYING /opt/bitnami/${TARGET_DIR}/licenses/${PACKAGE}-${VERSION}.txt
cp -f ${PACKAGE} /opt/bitnami/${TARGET_DIR}/bin/${PACKAGE}
popd
rm -rf ${PACKAGE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment