This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from NERSC/19-09
19 09
- Loading branch information
Showing
25 changed files
with
499 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ARG branch=unknown | ||
|
||
FROM registry.spin.nersc.gov/das/jupyter-base-${branch}:latest | ||
LABEL maintainer="Rollin Thomas <rcthomas@lbl.gov>" | ||
|
||
RUN \ | ||
pip install git+https://github.com/rcthomas/jupyterhub-announcement.git@persist-announcements | ||
|
||
WORKDIR /srv | ||
|
||
ADD docker-entrypoint.sh announcement_config.py ./ | ||
RUN chmod +x docker-entrypoint.sh | ||
ENTRYPOINT ["./docker-entrypoint.sh"] | ||
CMD ["python", "-m", "jupyterhub_announcement"] |
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,72 @@ | ||
# Configuration file for application. | ||
|
||
#------------------------------------------------------------------------------ | ||
# Application(SingletonConfigurable) configuration | ||
#------------------------------------------------------------------------------ | ||
|
||
## This is an application. | ||
|
||
## The date format used by logging formatters for %(asctime)s | ||
#c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S' | ||
|
||
## The Logging format template | ||
#c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s' | ||
|
||
## Set the log level by value or name. | ||
#c.Application.log_level = 30 | ||
c.Application.log_level = 0 | ||
|
||
#------------------------------------------------------------------------------ | ||
# AnnouncementService(Application) configuration | ||
#------------------------------------------------------------------------------ | ||
|
||
## This is an application. | ||
|
||
## Config file to load | ||
#c.AnnouncementService.config_file = 'announcement_config.py' | ||
|
||
## Fixed message to show at the top of the page. | ||
# | ||
# A good use for this parameter would be a link to a more general live system | ||
# status page or MOTD. | ||
#c.AnnouncementService.fixed_message = '' | ||
|
||
## Generate default config file | ||
#c.AnnouncementService.generate_config = False | ||
|
||
## Logo path, can be used to override JupyterHub one | ||
#c.AnnouncementService.logo_file = '' | ||
|
||
## Port this service will listen on | ||
#c.AnnouncementService.port = 8888 | ||
|
||
## Announcement service prefix | ||
#c.AnnouncementService.service_prefix = '/services/announcement/' | ||
|
||
## Search paths for jinja templates, coming before default ones | ||
#c.AnnouncementService.template_paths = [] | ||
|
||
#------------------------------------------------------------------------------ | ||
# AnnouncementQueue(LoggingConfigurable) configuration | ||
#------------------------------------------------------------------------------ | ||
|
||
## File path where announcements persist as JSON. | ||
# | ||
# For a persistent announcement queue, this parameter must be set to a non-empty | ||
# value and correspond to a read+write-accessible path. The announcement queue | ||
# is stored as a list of JSON objects. If this parameter is set to a non-empty | ||
# value: | ||
# | ||
# * The persistence file is used to initialize the announcement queue | ||
# at start-up. This is the only time the persistence file is read. | ||
# * If the persistence file does not exist at start-up, it is | ||
# created when an announcement is added to the queue. | ||
# * The persistence file is over-written with the contents of the | ||
# announcement queue each time a new announcement is added. | ||
# | ||
# If this parameter is set to an empty value (the default) then the queue is | ||
# just empty at initialization and the queue is ephemeral; announcements will | ||
# not be persisted on updates to the queue. | ||
#c.AnnouncementQueue.persist_path = '' | ||
c.AnnouncementQueue.persist_path = 'announcements.json' | ||
|
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,8 @@ | ||
#!/bin/bash | ||
|
||
branch=$(git symbolic-ref --short HEAD) | ||
|
||
docker build \ | ||
--build-arg branch=$branch \ | ||
"$@" \ | ||
--tag web-announcement:latest . |
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,28 @@ | ||
#!/bin/bash | ||
|
||
# file_env VAR [DEFAULT] | ||
# ---------------------- | ||
# Treat the value of VAR_FILE as the path to a secrets file and initialize VAR | ||
# with the contents of that file. From postgres docker-entrypoint.sh. | ||
|
||
file_env() { | ||
local var="$1" | ||
local fileVar="${var}_FILE" | ||
local def="${2:-}" | ||
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then | ||
echo >&2 "error: both $var and $fileVar are set (but are exclusive)" | ||
exit 1 | ||
fi | ||
local val="$def" | ||
if [ "${!var:-}" ]; then | ||
val="${!var}" | ||
elif [ "${!fileVar:-}" ]; then | ||
val="$(< "${!fileVar}")" | ||
fi | ||
export "$var"="$val" | ||
unset "$fileVar" | ||
} | ||
|
||
file_env 'JUPYTERHUB_API_TOKEN' | ||
|
||
exec "$@" |
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,24 @@ | ||
{% extends "templates/page.html" %} | ||
{% block announcement %} | ||
<div class="container announcement"> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block script %} | ||
{{ super() }} | ||
<script> | ||
$.get("/services/announcement/latest", function(data) { | ||
var announcement = data["announcement"]; | ||
if(announcement) { | ||
$(".announcement").html(`<div class="panel panel-warning"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Announcement</h3> | ||
</div> | ||
<div class="panel-body text-center announcement"> | ||
${announcement} | ||
</div> | ||
</div>`); | ||
} | ||
}); | ||
</script> | ||
{% endblock %} |
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,72 @@ | ||
# Configuration file for application. | ||
|
||
#------------------------------------------------------------------------------ | ||
# Application(SingletonConfigurable) configuration | ||
#------------------------------------------------------------------------------ | ||
|
||
## This is an application. | ||
|
||
## The date format used by logging formatters for %(asctime)s | ||
#c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S' | ||
|
||
## The Logging format template | ||
#c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s' | ||
|
||
## Set the log level by value or name. | ||
#c.Application.log_level = 30 | ||
c.AnnouncementService.log_level = 0 | ||
|
||
#------------------------------------------------------------------------------ | ||
# AnnouncementService(Application) configuration | ||
#------------------------------------------------------------------------------ | ||
|
||
## This is an application. | ||
|
||
## Config file to load | ||
#c.AnnouncementService.config_file = 'announcement_config.py' | ||
|
||
## Fixed message to show at the top of the page. | ||
# | ||
# A good use for this parameter would be a link to a more general live system | ||
# status page or MOTD. | ||
#c.AnnouncementService.fixed_message = '' | ||
|
||
## Generate default config file | ||
#c.AnnouncementService.generate_config = False | ||
|
||
## Logo path, can be used to override JupyterHub one | ||
#c.AnnouncementService.logo_file = '' | ||
|
||
## Port this service will listen on | ||
#c.AnnouncementService.port = 8888 | ||
|
||
## Announcement service prefix | ||
#c.AnnouncementService.service_prefix = '/services/announcement/' | ||
|
||
## Search paths for jinja templates, coming before default ones | ||
#c.AnnouncementService.template_paths = [] | ||
|
||
#------------------------------------------------------------------------------ | ||
# AnnouncementQueue(LoggingConfigurable) configuration | ||
#------------------------------------------------------------------------------ | ||
|
||
## File path where announcements persist as JSON. | ||
# | ||
# For a persistent announcement queue, this parameter must be set to a non-empty | ||
# value and correspond to a read+write-accessible path. The announcement queue | ||
# is stored as a list of JSON objects. If this parameter is set to a non-empty | ||
# value: | ||
# | ||
# * The persistence file is used to initialize the announcement queue | ||
# at start-up. This is the only time the persistence file is read. | ||
# * If the persistence file does not exist at start-up, it is | ||
# created when an announcement is added to the queue. | ||
# * The persistence file is over-written with the contents of the | ||
# announcement queue each time a new announcement is added. | ||
# | ||
# If this parameter is set to an empty value (the default) then the queue is | ||
# just empty at initialization and the queue is ephemeral; announcements will | ||
# not be persisted on updates to the queue. | ||
#c.AnnouncementQueue.persist_path = '' | ||
c.AnnouncementQueue.persist_path = 'announcements.json' | ||
|
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,14 @@ | ||
ARG branch=unknown | ||
|
||
FROM registry.spin.nersc.gov/das/jupyter-base-${branch}:latest | ||
LABEL maintainer="Rollin Thomas <rcthomas@lbl.gov>" | ||
|
||
RUN \ | ||
pip install git+https://github.com/rcthomas/jupyterhub-announcement.git@persist-announcements | ||
|
||
WORKDIR /srv | ||
|
||
ADD docker-entrypoint.sh announcement_config.py ./ | ||
RUN chmod +x docker-entrypoint.sh | ||
ENTRYPOINT ["./docker-entrypoint.sh"] | ||
CMD ["python", "-m", "jupyterhub_announcement"] |
Oops, something went wrong.