Skip to content
Snippets Groups Projects
David Hoese's avatar
0c35d724

RAIN Website

Production Site: https://metobs.ssec.wisc.edu/ Test Site: https://metobs-test.ssec.wisc.edu/ Git Repository: https://gitlab.ssec.wisc.edu/metobs/MetObsSite/

The RAIN (MetObs) website is a generated static website that uses the Python "pelican" package to do the rendering.

Development Server

To run this site locally requires a python environment with the "pelican" package installed. With that environment active, run:

make clean
make devserver

The server should serve the website at "http://localhost:8000". The server will write output to output and will automatically rerender files as you make changes to the files in content. It can sometimes get out of sync so use Ctrl+C to kill the server and restart it with make devserver.

Publishing the Website

As mentioned above, the website is published to two locations. The main production site is published as https://metobs.ssec.wisc.edu and the development/test site is published as https://metobs-test.ssec.wisc.edu. Both of these sites are generated from the SSEC GitLab repository; the production site from the master branch and the test site from the develop branch.

These domains should be updated automatically by a GitLab Runner when changes are made to the appropriate branches. To manually make this output you can run:

make clean
make publish

However, there are some gotchas with this which is why the GitLab Runner approach was chosen for publishing. The main gotcha is that any files referenced from inside the templates (ex. {filename}/js/quicklook.js) will be updated with an absolute URL to https://metobs.ssec.wisc.edu. There is no easy way to customize this based on what branch is being used without manually editing pelican configuration. This would cause the test site to look at the production site for these assets which is not what we want.

Setting up a GitLab Runnner

After following GitLab instructions for registering a new GitLab runner, we need to do some extra setup to prepare the runner's account. See the .gitlab-ci.yml file for the exact commands that are run for each job.

At the time of writing a runner is registered on the rain01 server with a "shell" executor with everything running under the gitlab-runner user account.

Add conda to the runner's environment

The GitLab CI configuration expects the runner to know what the "conda" command is. To enable this we run a onetime command on the runner which initializes a bashrc for the gitlab-runner user.

sudo -u gitlab-runner /home/davidh/miniconda3/bin/conda init bash

Or where ever conda is installed for this system. This will create a bashrc file for the gitlab-runner user to make the conda command available. This is used in the .gitlab-ci.yml scripts for creating a build environment.

GitLab Runner Upload

The uploading of the generated website content is done with rsync via SSH. This currently uses two SSH keys under David Hoese's user account (davidh) on the webaccess server. These keys are restricted to only run the specific rsync commands used by gitlab-ci. This is configured in the ~/.ssh/authorized_keys file:

command="rsync --server -vulogDtpre.iLsfxC --delete . METOBS_TEST",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa <key> metobs-test upload key

The above is specifically for the "metobs-test" site. METOBS_TEST is a symbolic link in webaccess:/home/davidh/ that points to the location of the metobs-test site's htdocs directory:

ln -s /webdata/web/metobs-test/htdocs METOBS_TEST

A similar setup should be used for a separate "production" key.