-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker-jans-monolith): add docker jans monolith (#2323)
* feat: add monolith image for test and dev * feat: finish Dockerfile and docker compose * docs: add table of info * ci: add quick run * fix: volumes * fix: scim env name * docs: add quick start command * fix: add clean up command to the quick start * fix: clean up * fix: conform to hadolint rules * fix: update linux installer * feat: add installation check * fix: add gitignore rules for volumes * fix(monolith): remove deployment flag volume Co-authored-by: iromli <isman.firmansyah@gmail.com> Former-commit-id: c31c393
- Loading branch information
Showing
15 changed files
with
620 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
JANS_FQDN=$1 | ||
JANS_PERSISTENCE=$2 | ||
|
||
if [[ ! "$JANS_FQDN" ]]; then | ||
read -rp "Enter Hostname [demoexample.jans.io]: " JANS_FQDN | ||
fi | ||
if [[ ! "$JANS_PERSISTENCE" ]]; then | ||
read -rp "Enter persistence type [LDAP(NOT SUPPORTED YET)|MYSQL]: " JANS_PERSISTENCE | ||
fi | ||
|
||
if [[ -z $EXT_IP ]]; then | ||
EXT_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) | ||
fi | ||
|
||
sudo apt-get update | ||
# Install Docker and Docker compose plugin | ||
sudo apt-get remove docker docker-engine docker.io containerd runc -y || echo "Docker doesn't exist..installing.." | ||
sudo apt-get update | ||
sudo apt-get install \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
lsb-release -y | ||
sudo mkdir -p /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt-get update | ||
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y | ||
WORKING_DIRECTORY=$PWD | ||
# note that as we're pulling from a monorepo (with multiple project in it) | ||
# we are using partial-clone and sparse-checkout to get the docker-jans-monolith code | ||
rm -rf /tmp/jans || echo "/tmp/jans doesn't exist" | ||
git clone --filter blob:none --no-checkout https://github.com/janssenproject/jans /tmp/jans \ | ||
&& cd /tmp/jans \ | ||
&& git sparse-checkout init --cone \ | ||
&& git checkout main \ | ||
&& git sparse-checkout set docker-jans-monolith \ | ||
&& cd "$WORKING_DIRECTORY" | ||
|
||
if [[ $JANS_PERSISTENCE == "MYSQL" ]]; then | ||
docker compose -f /tmp/jans/docker-jans-monolith/mysql-docker-compose.yml up -d | ||
fi | ||
echo "$EXT_IP $JANS_FQDN" | sudo tee -a /etc/hosts > /dev/null | ||
echo "Waiting for the Janssen server to come up. Depending on the resources it may take 3-5 mins for the services to be up." | ||
sleep 180 | ||
cat << EOF > testendpoints.sh | ||
echo -e "Testing openid-configuration endpoint.. \n" | ||
curl -k https://$JANS_FQDN/.well-known/openid-configuration | ||
echo -e "Testing scim-configuration endpoint.. \n" | ||
curl -k https://$JANS_FQDN/.well-known/scim-configuration | ||
echo -e "Testing fido2-configuration endpoint.. \n" | ||
curl -k https://$JANS_FQDN/.well-known/fido2-configuration | ||
EOF | ||
sudo bash testendpoints.sh | ||
echo -e "You may re-execute bash testendpoints.sh to do a quick test to check the configuration endpoints." | ||
echo -e "Add the following record to your local computers' hosts file to engage with the services $EXT_IP $JANS_FQDN" | ||
echo -e "To clean up run:" | ||
echo -e "docker compose -f /tmp/jans/docker-jans-monolith/mysql-docker-compose.yml down && rm -rf /tmp/jans" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*-custom | ||
jans-deployed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ignored: | ||
- SC1083 | ||
- DL3008 # Pin versions in apt-get | ||
- DL3013 # Pin versions in pip | ||
- DL3015 # Specify --no-install-recommends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
FROM ubuntu:20.04 | ||
|
||
# Don't start any optional services except for the few we need. | ||
RUN find /etc/systemd/system \ | ||
/lib/systemd/system \ | ||
-path '*.wants/*' \ | ||
-not -name '*journald*' \ | ||
-not -name '*systemd-tmpfiles*' \ | ||
-not -name '*systemd-user-sessions*' \ | ||
-exec rm \{} \; | ||
|
||
# Disable list of suggested/ recommended dependencies | ||
RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker \ | ||
&& echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker | ||
|
||
# Prevent prompt errors during package installation | ||
RUN DEBIAN_FRONTEND=noninteractive \ | ||
apt-get update \ | ||
&& apt-get install -y python3 tini curl ca-certificates dbus systemd iproute2 gpg python3-pip \ | ||
&& apt-get clean \ | ||
# Cleaning up package lists | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
RUN systemctl set-default multi-user.target \ | ||
&& systemctl mask dev-hugepages.mount sys-fs-fuse-connections.mount | ||
|
||
# Workaround agetty high CPU. https://bugzilla.redhat.com/show_bug.cgi?id=1046469 | ||
RUN rm -f /lib/systemd/system/systemd*udev* \ | ||
&& rm -f /lib/systemd/system/getty.target | ||
|
||
HEALTHCHECK --interval=35s --timeout=4s CMD /opt/dist/scripts/jans-auth check | grep "Jetty running pid" || exit 1 | ||
|
||
# Ports required by jetty | ||
EXPOSE 443 8080 1636 | ||
|
||
# ===================== | ||
# jans-linux-setup | ||
# ===================== | ||
|
||
ENV JANS_SOURCE_VERSION=732ce6afb18fb1f352dfbf4ce971039b8824bc36 | ||
|
||
# cleanup | ||
RUN rm -rf /tmp/jans | ||
|
||
# ====== | ||
# Python | ||
# ====== | ||
COPY requirements.txt /app/requirements.txt | ||
RUN pip3 install --no-cache-dir -U pip wheel \ | ||
&& pip3 install --no-cache-dir -r /app/requirements.txt \ | ||
&& pip3 uninstall -y pip wheel | ||
|
||
# ======= | ||
# License | ||
# ======= | ||
|
||
COPY LICENSE /licenses/LICENSE | ||
|
||
# ========== | ||
# SETUP ENVS | ||
# ========== | ||
|
||
ENV CN_HOSTNAME="demoexample.jans.io" \ | ||
CN_ADMIN_PASS="" \ | ||
CN_ORG_NAME="Janssen" \ | ||
CN_EMAIL="support.jans.io" \ | ||
CN_CITY="Austin" \ | ||
CN_STATE="TX" \ | ||
CN_COUNTRY="US" \ | ||
# Install with local mysql by default | ||
INSTALL_LDAP="false" \ | ||
CN_INSTALL_CONFIG_API="true" \ | ||
CN_INSTALL_SCIM="true" \ | ||
CN_INSTALL_FIDO2="true" \ | ||
CN_INSTALL_CLIENT_API="true" \ | ||
MYSQL_DATABASE="jans" \ | ||
MYSQL_USER="jans" \ | ||
MYSQL_PASSWORD="" | ||
|
||
# ========== | ||
# misc stuff | ||
# ========== | ||
|
||
LABEL name="janssenproject/monolith" \ | ||
maintainer="Janssen Project <support@jans.io>" \ | ||
vendor="Janssen Project" \ | ||
version="1.0.3" \ | ||
release="dev" \ | ||
summary="Janssen Monolith Image" \ | ||
description="Janssen Authorization server" | ||
|
||
COPY scripts /app/scripts | ||
RUN chmod +x /app/scripts/entrypoint.sh | ||
|
||
CMD ["/bin/bash", "-c", "exec /app/scripts/entrypoint.sh --log-target=journal 3>&1"] |
Oops, something went wrong.