# https://www.mongodb.com/zh-cn/docs/v8.2/tutorial/install-mongodb-on-red-hat/#install-mongodb-community-edition
# https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.2/x86_64/RPMS/

FROM oraclelinux:9-slim-fips

# 1. 更新系统并安装核心依赖
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
# RUN set -eux; \
# 	groupadd --gid 999 --system mongodb; \
# 	useradd --uid 999 --system --gid mongodb --home-dir /data/db mongodb; \
# 	mkdir -p /data/db /data/configdb; \
# 	chown -R mongodb:mongodb /data/db /data/configdb


RUN set -eux; \
	microdnf update -y; \
    microdnf upgrade -y;


RUN set -eux; \
	{ \
		echo '[mongodb-org-8.2]'; \
		echo 'name=MongoDB Repository'; \
		echo 'baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.2/x86_64/'; \
		echo 'gpgcheck=1'; \
		echo 'enabled=1'; \
		echo 'gpgkey=https://pgp.mongodb.com/server-8.0.asc'; \
	} | tee /etc/yum.repos.d/mongodb-org-8.2.repo

 RUN set -eux; \
    microdnf install -y \
	"mongodb-org-server"

    # RUN set -eux; \
	# microdnf install -y \
	# "mongodb-org" \
	# "mongodb-org-database" \
	# "mongodb-mongosh"  \
	# "mongodb-org-tools" ; \
	# mv /etc/mongod.conf /etc/mongod.conf.orig

# COPY bin/  /usr/bin/
# RUN set -eux; \
# 	chmod +x /usr/bin/mongotop; \
# 	chmod +x /usr/bin/bsondump; \
# 	chmod +x /usr/bin/mongodump; \
# 	chmod +x /usr/bin/mongoexport; \
# 	chmod +x /usr/bin/mongofiles; \
# 	chmod +x /usr/bin/mongoimport; \
#   chmod +x /usr/bin/mongorestore; \
#   chmod +x /usr/bin/mongostat;


# RUN set -eux; \
# 	microdnf -y install  curl-7.76.1-35.el9_7.3  libcurl-7.76.1-35.el9_7.3;

RUN set -eux; \
    microdnf clean all ; 

RUN set -eux; \
    rpm -e --nodeps expat glib2 curl libcurl libssh libssh-config

 COPY  usr/lib64/   /usr/lib64/

VOLUME /data/db /data/configdb
ENV HOME=/data/db

EXPOSE 27017
CMD ["mongod", "--bind_ip_all"]


# docker build -t  registry.cn-shanghai.aliyuncs.com/hub_z/mongo:8.2  .
# docker push  registry.cn-shanghai.aliyuncs.com/hub_z/mongo:8.2
# syft  --scope  squashed  registry.cn-shanghai.aliyuncs.com/hub_z/mongo:8.2    -o  spdx-json=mongo.json

# rpmextract.sh libcurl-7.76.1-35.el9_7.3.x86_64.rpm

