-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
56 lines (45 loc) · 2.77 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
FROM docker.io/amd64/debian:11-slim@sha256:eba49f684e76d007f9cc1a6376aea65eee5d2e41d6d0481de1c9704d7bd382d8
LABEL maintainer="ownCloud DevOps <devops@owncloud.com>"
LABEL org.opencontainers.image.authors="ownCloud DevOps <devops@owncloud.com>"
LABEL org.opencontainers.image.title="MongoDB"
LABEL org.opencontainers.image.url="https://github.com/owncloud-ops/mongodb"
LABEL org.opencontainers.image.source="https://github.com/owncloud-ops/mongodb"
LABEL org.opencontainers.image.documentation="https://github.com/owncloud-ops/mongodb"
ARG BUILD_VERSION
ARG CONTAINER_LIBRARY_VERSION
ARG DEBIAN_FRONTEND=noninteractive
# renovate: datasource=github-releases depName=hairyhenderson/gomplate
ENV GOMPLATE_VERSION="${GOMPLATE_VERSION:-v3.11.7}"
# renovate: datasource=docker depName=mongo
ENV MONGO_RAW_VERSION="${BUILD_VERSION:-5.0.26}"
# renovate: datasource=github-releases depName=owncloud-ops/container-library
ENV CONTAINER_LIBRARY_VERSION="${CONTAINER_LIBRARY_VERSION:-v0.1.0}"
ENV MONGO_DATA_DIR="${MONGO_DATA_DIR:-/opt/mongo}"
ADD overlay/ /
RUN addgroup --gid 101 --system mongodb && \
adduser --system --disabled-password --no-create-home --uid 101 --home "${MONGO_DATA_DIR}" --shell /sbin/nologin --ingroup mongodb --gecos mongodb mongodb && \
apt-get update && apt-get install -y wget curl gnupg2 procps apt-transport-https ca-certificates perl-base && \
curl -SsfL -o /usr/local/bin/gomplate "https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_linux-amd64-slim" && \
curl -SsfL "https://github.com/owncloud-ops/container-library/releases/download/${CONTAINER_LIBRARY_VERSION}/container-library.tar.gz" | tar xz -C / && \
chmod 755 /usr/local/bin/gomplate && \
MONGO_VERSION=${MONGO_RAW_VERSION%.*} && \
echo "Setup MongoDB 'v$MONGO_VERSION'" && \
curl -SsfL "https://www.mongodb.org/static/pgp/server-$MONGO_VERSION.asc" | gpg --dearmor |\
tee -a /usr/share/keyrings/mongodb-org.gpg >/dev/null && \
echo "deb [signed-by=/usr/share/keyrings/mongodb-org.gpg] https://repo.mongodb.org/apt/debian buster/mongodb-org/$MONGO_VERSION main" |\
tee -a "/etc/apt/sources.list.d/mongodb-org.list" >/dev/null && \
apt-get update && apt-get install -y mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools && \
mkdir -p "${MONGO_DATA_DIR}"/db && \
mkdir -p "${MONGO_DATA_DIR}"/dump && \
mkdir -p "${MONGO_DATA_DIR}"/conf && \
mkdir -p "${MONGO_DATA_DIR}"/tmp && \
chown -R mongodb:mongodb "${MONGO_DATA_DIR}" && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*
VOLUME "${MONGO_DATA_DIR}"/db
EXPOSE 27017
USER mongodb
ENTRYPOINT ["/usr/bin/entrypoint", "server"]
HEALTHCHECK --interval=15s --timeout=5s --retries=10 CMD /usr/bin/healthcheck
WORKDIR "${MONGO_DATA_DIR}"
CMD []