Skip to content

Commit b478f14

Browse files
PCSM-235. Add dockerfiles (#1259)
1 parent 5d1c197 commit b478f14

File tree

3 files changed

+194
-0
lines changed

3 files changed

+194
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM redhat/ubi9-minimal
2+
3+
# Please don't remove old-style LABEL since it's needed for RedHat certification
4+
LABEL name="Percona ClusterSync for MongoDB" \
5+
maintainer="Percona Development <info@percona.com>" \
6+
vendor="Percona" \
7+
summary="Percona ClusterSync for MongoDB" \
8+
description="Percona ClusterSync for MongoDB is a tool for \
9+
replicating data from a source MongoDB cluster to a target MongoDB cluster." \
10+
org.opencontainers.image.authors="info@percona.com"
11+
12+
LABEL org.opencontainers.image.title="Percona ClusterSync for MongoDB" \
13+
org.opencontainers.image.vendor="Percona" \
14+
org.opencontainers.image.description="Percona ClusterSync for MongoDB is a tool for \
15+
replicating data from a source MongoDB cluster to a target MongoDB cluster." \
16+
org.opencontainers.image.authors="info@percona.com"
17+
18+
ENV PCSM_VERSION 0.6.0-1
19+
ENV PCSM_REPO_CH experimental
20+
ENV OS_VER el9
21+
ENV FULL_PCSM_VERSION "$PCSM_VERSION.$OS_VER"
22+
23+
# check repository package signature in secure way
24+
RUN set -ex; \
25+
export GNUPGHOME="$(mktemp -d)"; \
26+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 4D1BB29D63D98E422B2113B19334A25F8507EFA5 99DB70FAE1D7CE227FB6488205B555B38483C65D 94E279EB8D8F25B21810ADF121EA45AB2F86D6A1; \
27+
gpg --batch --export --armor 4D1BB29D63D98E422B2113B19334A25F8507EFA5 > ${GNUPGHOME}/PERCONA-PACKAGING-KEY; \
28+
gpg --batch --export --armor 99DB70FAE1D7CE227FB6488205B555B38483C65D > ${GNUPGHOME}/RPM-GPG-KEY-centosofficial; \
29+
gpg --batch --export --armor 94E279EB8D8F25B21810ADF121EA45AB2F86D6A1 > ${GNUPGHOME}/RPM-GPG-KEY-EPEL-9; \
30+
rpmkeys --import ${GNUPGHOME}/PERCONA-PACKAGING-KEY ${GNUPGHOME}/RPM-GPG-KEY-centosofficial ${GNUPGHOME}/RPM-GPG-KEY-EPEL-9; \
31+
microdnf install -y findutils; \
32+
curl -Lf -o /tmp/percona-release.rpm https://repo.percona.com/yum/percona-release-latest.noarch.rpm; \
33+
rpmkeys --checksig /tmp/percona-release.rpm; \
34+
rpm -i /tmp/percona-release.rpm; \
35+
rm -rf "$GNUPGHOME" /tmp/percona-release.rpm; \
36+
rpm --import /etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY; \
37+
percona-release enable pcsm ${PCSM_REPO_CH}; \
38+
percona-release enable psmdb-80 release
39+
40+
RUN set -ex; \
41+
microdnf -y update; \
42+
microdnf -y install \
43+
vim-minimal \
44+
jq \
45+
oniguruma; \
46+
microdnf -y install \
47+
percona-clustersync-mongodb-${FULL_PCSM_VERSION}; \
48+
microdnf -y install percona-server-mongodb-shell; \
49+
microdnf clean all; \
50+
rm -rf /var/cache/dnf /var/cache/yum
51+
52+
RUN mkdir -p /licenses && \
53+
curl -Lf -o /licenses/LICENSE.Dockerfile https://raw.githubusercontent.com/percona/percona-clustersync-mongodb/refs/heads/main/LICENSE && \
54+
curl -Lf -o /licenses/LICENSE.Percona-ClusterSync-for-MongoDB https://raw.githubusercontent.com/percona/percona-clustersync-mongodb/refs/heads/main/LICENSE
55+
56+
COPY pcsm-entry.sh /pcsm-entry.sh
57+
RUN chmod +x /pcsm-entry.sh
58+
59+
RUN useradd -u 1001 -r -g 0 -m -s /sbin/nologin \
60+
-c "Default Application User" mongodb;
61+
USER 1001
62+
63+
# Containers should be started either with --source and --target flags or with PCSM_SOURCE_URI and PCSM_TARGET_URI env variables
64+
ENTRYPOINT ["/pcsm-entry.sh"]
65+
CMD ["pcsm"]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
FROM redhat/ubi9-minimal
2+
3+
# Please don't remove old-style LABEL since it's needed for RedHat certification
4+
LABEL name="Percona ClusterSync for MongoDB" \
5+
maintainer="Percona Development <info@percona.com>" \
6+
vendor="Percona" \
7+
summary="Percona ClusterSync for MongoDB" \
8+
description="Percona ClusterSync for MongoDB is a tool for \
9+
replicating data from a source MongoDB cluster to a target MongoDB cluster." \
10+
org.opencontainers.image.authors="info@percona.com"
11+
12+
LABEL org.opencontainers.image.title="Percona ClusterSync for MongoDB" \
13+
org.opencontainers.image.vendor="Percona" \
14+
org.opencontainers.image.description="Percona ClusterSync for MongoDB is a tool for \
15+
replicating data from a source MongoDB cluster to a target MongoDB cluster." \
16+
org.opencontainers.image.authors="info@percona.com"
17+
18+
ENV PCSM_VERSION 0.6.0-1
19+
ENV PCSM_REPO_CH experimental
20+
ENV OS_VER el9
21+
ENV FULL_PCSM_VERSION "$PCSM_VERSION.$OS_VER"
22+
23+
# check repository package signature in secure way
24+
RUN set -ex; \
25+
export GNUPGHOME="$(mktemp -d)"; \
26+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 4D1BB29D63D98E422B2113B19334A25F8507EFA5 99DB70FAE1D7CE227FB6488205B555B38483C65D 94E279EB8D8F25B21810ADF121EA45AB2F86D6A1; \
27+
gpg --batch --export --armor 4D1BB29D63D98E422B2113B19334A25F8507EFA5 > ${GNUPGHOME}/PERCONA-PACKAGING-KEY; \
28+
gpg --batch --export --armor 99DB70FAE1D7CE227FB6488205B555B38483C65D > ${GNUPGHOME}/RPM-GPG-KEY-centosofficial; \
29+
gpg --batch --export --armor 94E279EB8D8F25B21810ADF121EA45AB2F86D6A1 > ${GNUPGHOME}/RPM-GPG-KEY-EPEL-9; \
30+
rpmkeys --import ${GNUPGHOME}/PERCONA-PACKAGING-KEY ${GNUPGHOME}/RPM-GPG-KEY-centosofficial ${GNUPGHOME}/RPM-GPG-KEY-EPEL-9; \
31+
microdnf install -y findutils; \
32+
curl -Lf -o /tmp/percona-release.rpm https://repo.percona.com/yum/percona-release-latest.noarch.rpm; \
33+
rpmkeys --checksig /tmp/percona-release.rpm; \
34+
rpm -i /tmp/percona-release.rpm; \
35+
rm -rf "$GNUPGHOME" /tmp/percona-release.rpm; \
36+
rpm --import /etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY; \
37+
sed -i "s|x86_64|x86_64 aarch64|" /usr/bin/percona-release; \
38+
percona-release enable pcsm ${PCSM_REPO_CH}; \
39+
percona-release enable psmdb-80 release
40+
41+
RUN set -ex; \
42+
microdnf -y update; \
43+
microdnf -y install \
44+
vim-minimal \
45+
jq \
46+
oniguruma; \
47+
microdnf -y install \
48+
percona-clustersync-mongodb-${FULL_PCSM_VERSION}; \
49+
microdnf -y install percona-server-mongodb-shell; \
50+
microdnf clean all; \
51+
rm -rf /var/cache/dnf /var/cache/yum
52+
53+
RUN mkdir -p /licenses && \
54+
curl -Lf -o /licenses/LICENSE.Dockerfile https://raw.githubusercontent.com/percona/percona-clustersync-mongodb/refs/heads/main/LICENSE && \
55+
curl -Lf -o /licenses/LICENSE.Percona-ClusterSync-for-MongoDB https://raw.githubusercontent.com/percona/percona-clustersync-mongodb/refs/heads/main/LICENSE
56+
57+
COPY pcsm-entry.sh /pcsm-entry.sh
58+
RUN chmod +x /pcsm-entry.sh
59+
60+
RUN useradd -u 1001 -r -g 0 -m -s /sbin/nologin \
61+
-c "Default Application User" mongodb;
62+
USER 1001
63+
64+
# Containers should be started either with --source and --target flags or with PCSM_SOURCE_URI and PCSM_TARGET_URI env variables
65+
ENTRYPOINT ["/pcsm-entry.sh"]
66+
CMD ["pcsm"]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
set -e
3+
4+
has_source_flag=false
5+
has_target_flag=false
6+
7+
for arg in "$@"; do
8+
case "$arg" in
9+
--source|--source=*)
10+
has_source_flag=true
11+
;;
12+
--target|--target=*)
13+
has_target_flag=true
14+
;;
15+
esac
16+
done
17+
18+
args=()
19+
if [ "$has_source_flag" = false ] || [ "$has_target_flag" = false ]; then
20+
if [ -n "${PCSM_SOURCE_URI:-}" ] && [ "$has_source_flag" = false ]; then
21+
args+=(--source="$PCSM_SOURCE_URI")
22+
fi
23+
if [ -n "${PCSM_TARGET_URI:-}" ] && [ "$has_target_flag" = false ]; then
24+
args+=(--target="$PCSM_TARGET_URI")
25+
fi
26+
fi
27+
28+
has_source=false
29+
if [ "$has_source_flag" = true ]; then
30+
has_source=true
31+
elif [ -n "${PCSM_SOURCE_URI:-}" ]; then
32+
has_source=true
33+
fi
34+
35+
has_target=false
36+
if [ "$has_target_flag" = true ]; then
37+
has_target=true
38+
elif [ -n "${PCSM_TARGET_URI:-}" ]; then
39+
has_target=true
40+
fi
41+
42+
if [ "$#" -eq 0 ] || [ "${1:0:1}" = '-' ] || [ "$1" = "pcsm" ]; then
43+
if [ "$has_source" = false ] || [ "$has_target" = false ]; then
44+
echo >&2 "ERROR: Both source and target MongoDB URIs should be provided"
45+
echo >&2 " Use --source and --target flags or"
46+
echo >&2 " Set PCSM_SOURCE_URI and PCSM_TARGET_URI environment variables"
47+
exit 1
48+
fi
49+
fi
50+
51+
# If command starts with an option, prepend pcsm
52+
if [ "$#" -eq 0 ] || [ "${1:0:1}" = '-' ]; then
53+
# Prepend pcsm and add any environment variable arguments
54+
set -- pcsm "${args[@]}" "$@"
55+
elif [ "$1" = "pcsm" ]; then
56+
# pcsm is already the first argument, insert env var args after it
57+
set -- pcsm "${args[@]}" "${@:2}"
58+
else
59+
# Custom command, don't modify
60+
set -- "$@"
61+
fi
62+
63+
exec "$@"

0 commit comments

Comments
 (0)