Skip to content

Commit

Permalink
webui: prepare containers with NextJS
Browse files Browse the repository at this point in the history
  • Loading branch information
Eraldo Jr authored and maany committed Oct 12, 2023
1 parent 4c880cd commit c08a223
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 49 deletions.
2 changes: 1 addition & 1 deletion server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ then
for patchfile in /patch/*
do
echo "Apply patch ${patchfile}"
patch -p3 -d "$RUCIO_PYTHON_PATH" < $patchfile
patch -p3 -d "$RUCIO_WEBUI_PATH" < $patchfile
done
fi

Expand Down
41 changes: 31 additions & 10 deletions webui/.env.default.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
[rucio_endpoint]
REACT_APP_RUCIO_HOST = {{ RUCIO_HOST | default('https://rucio-host-not-defined') }}

[login_page_org_images]
{% if WEBUI_LOGIN_PAGE_IMAGE_PRIMARY is defined %}
REACT_APP_login_page_image_primary = {{ WEBUI_LOGIN_PAGE_IMAGE_PRIMARY }}
{% endif %}
{% if WEBUI_LOGIN_PAGE_IMAGE_SECONDARY is defined %}
REACT_APP_login_page_image_secondary = {{ WEBUI_LOGIN_PAGE_IMAGE_SECONDARY }}
{% endif %}
[public]
NEXT_PUBLIC_WEBUI_HOST = {{ RUCIO_HOST | default('https://rucio-host-not-defined') }}

[meta]
PROJECT_NAME = {{PROJECT_NAME | default('https://atlas.cern/')}}

[session]
SESSION_PASSWORD = {{SESSION_PASSWORD | default('2gyZ3GDw3LHZQKDhPmPDL3sjREVRXPr8')}}
SESSION_COOKIE_NAME = {{SESSION_COOKIE_NAME | default('rucio-webui-session')}}
NODE_TLS_REJECT_UNAUTHORIZED = {{NODE_TLS_REJECT_UNAUTHORIZED | default('0')}}

[gateway]
RUCIO_AUTH_HOST = {{ RUCIO_AUTH_HOST | default('https://rucio-auth-host-not-defined') }}
RUCIO_HOST = {{ RUCIO_HOST | default('https://rucio-host-not-defined') }}

[oidc]
OIDC_ENABLED = {{ OIDC_ENABLED | default('false') }}
OIDC_PROVIDERS = {{ OIDC_PROVIDERS | default('') }}


{% if OIDC_PROVIDERS %}
{% set providers_list = OIDC_PROVIDERS.split(',') %}
{% for provider in providers_list %}
{% set provider_var_name = 'OIDC_PROVIDER_' + provider + '_CLIENT_ID' %}
{% set provider_value = '' %}
{% if provider_var_name in context %}
{% set provider_value = context[provider_var_name] %}
{% endif %}
OIDC_PROVIDER_{{ provider }}_CLIENT_ID={{ provider_value }}
{% endfor %}
{% endif %}
33 changes: 18 additions & 15 deletions webui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,38 @@
#
# Authors:
# - Mayank Sharma, <mayank.sharma@cern.ch>, 2022
# - Eraldo Junior <ejunior@cbpf.br>, 2023

FROM almalinux:9

FROM quay.io/centos/centos:stream8 as production
ARG TAG

LABEL stage=production
RUN dnf -y update && \
dnf -y module reset nodejs && \
dnf -y module enable nodejs:16 && \
dnf -y module install nodejs:16/common && \
dnf -y install httpd mod_ssl python39 git procps && \
dnf clean all

RUN python3 -m pip install --no-cache-dir --upgrade pip
dnf -y module enable nodejs:18 && \
dnf -y module install nodejs:18/common && \
dnf -y install httpd mod_ssl python39 python-pip git procps && \
dnf clean all && \
rm -rf /var/cache/dnf

RUN python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir --upgrade setuptools
RUN python3 -m pip install --no-cache-dir j2cli

WORKDIR /opt/rucio/webui

ENV RUCIO_WEBUI_PATH=$(WORKDIR)

RUN curl https://raw.githubusercontent.com/rucio/rucio/master/tools/merge_rucio_configs.py --output /opt/rucio/merge_rucio_configs.py
RUN git clone --depth 1 -b ${TAG} -- https://github.com/rucio/webui.git /opt/rucio/webui
RUN npm ci --legacy-peer-deps

COPY robots.txt /var/www/html
COPY httpd.conf.j2 /tmp/
COPY rucio.conf.j2 /tmp
RUN npm install
RUN npm run build

COPY docker-entrypoint.sh /
COPY .env.default.j2 /tmp/

RUN rm /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/userdir.conf /etc/httpd/conf.d/ssl.conf

VOLUME /var/log/httpd

EXPOSE 443
EXPOSE 80

Expand Down
37 changes: 14 additions & 23 deletions webui/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
#!/bin/bash -e

j2 /tmp/httpd.conf.j2 | sed '/^\s*$/d' > /etc/httpd/conf/httpd.conf

echo "=================== /etc/httpd/conf/httpd.conf ========================"
cat /etc/httpd/conf/httpd.conf
echo ""


j2 /tmp/rucio.conf.j2 | sed '/^\s*$/d' > /etc/httpd/conf.d/rucio.conf

echo "=================== /etc/httpd/conf.d/rucio.conf ========================"
cat /etc/httpd/conf.d/rucio.conf
echo ""

j2 /tmp/.env.default.j2 | sed '/^\s*$/d' > /opt/rucio/webui/.env.default

if [ -f /opt/rucio/webui/.env ]; then
echo "/opt/rucio/webui/.env already mounted."
else
echo "/opt/rucio/webui/.env not found. will generate one."
python3 /opt/rucio/merge_rucio_configs.py \
-s /opt/rucio/webui/.env.default $RUCIO_OVERRIDE_CONFIGS \
--use-env \
-d /opt/rucio/webui/.env
echo "/opt/rucio/webui/.env not found. will generate one."
j2 /tmp/.env.default.j2 | sed '/^\s*$/d' > /opt/rucio/webui/.env
fi

echo "=================== /opt/rucio/webui/.env ========================"
cat /opt/rucio/webui/.env
echo ""

npm run build
cp -rfn /opt/rucio/webui/build/* /var/www/html/
exec httpd -D FOREGROUND
if [ -d "/patch" ]
then
echo "Patches found. Trying to apply them"
for patchfile in /patch/*
do
echo "Apply patch ${patchfile}"
patch -p3 -d "$RUCIO_WEBUI_PATH" < $patchfile
done
fi

echo "=================== Starting RUCIO WEBUI ========================"
npm run start

0 comments on commit c08a223

Please sign in to comment.