-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/render hugo for docker (#17)
* Add learners config for docker deployment * Add db files to gitignore * Bind volumes * Remove unused folders * Add hugo render helper script * Change mount dirs Co-authored-by: Lenhard Reuter <lenhard.reuter@ait.ac.at>
- Loading branch information
1 parent
2dec805
commit 335dd83
Showing
5 changed files
with
135 additions
and
9 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
Empty file.
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,43 @@ | ||
# learners: | ||
# theme: "dark" | ||
|
||
jwt: | ||
jwt_secret_key: "53CR3T" | ||
jwt_for_vnc_access: False | ||
|
||
database: | ||
db_uri: "sqlite:////opt/learners/data/learners_tracker.db" | ||
|
||
documentation: | ||
directory: "/opt/learners/webroot/documentation" | ||
endpoint: "/documentation" | ||
|
||
exercises: | ||
directory: "/opt/learners/webroot/exercises" | ||
endpoint: "/exercises" | ||
|
||
callback: | ||
endpoint: "http://localhost:8080/callback" | ||
|
||
venjix: | ||
auth_secret: "53CR3T" | ||
url: "http://localhost:5001" | ||
|
||
novnc: | ||
server: "http://localhost:5002" | ||
|
||
screenSharing: True | ||
|
||
users: | ||
test: | ||
password: test | ||
is_presenter: True | ||
user1: | ||
password: user1 | ||
user2: | ||
password: user2 | ||
user3: | ||
password: user3 | ||
admin: | ||
is_admin: True | ||
password: admin |
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,79 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import yaml | ||
import sys, getopt | ||
|
||
|
||
def main(argv): | ||
contentBaseDir = "" | ||
outputDir = "" | ||
config_file = "" | ||
|
||
try: | ||
opts, args = getopt.getopt(argv, "hi:o:c:", ["input=", "output=", "config="]) | ||
except getopt.GetoptError: | ||
print("render_content.py -i <contentBaseDir> -o <outputDir> -c <configFile>") | ||
sys.exit(2) | ||
for opt, arg in opts: | ||
if opt == "-h": | ||
print("render_content.py -i <contentBaseDir> -o <outputDir> -c <configFile>") | ||
sys.exit() | ||
elif opt in ("-i", "--input"): | ||
contentBaseDir = arg | ||
elif opt in ("-o", "--output"): | ||
outputDir = arg | ||
elif opt in ("-c", "--config"): | ||
config_file = arg | ||
|
||
currentDir = os.getcwd() | ||
|
||
if not outputDir: | ||
outputDir = f"{currentDir}/rendered_hugo_content" | ||
|
||
if not contentBaseDir: | ||
print( | ||
"Please specify the content base directory (directory of the hugo files)\nrender_content.py -i <absolute path> or\nrender_content.py --input <absolute path>" | ||
) | ||
return | ||
|
||
if not config_file: | ||
config_file = os.getenv("LEARNERS_CONFIG") or os.path.join(currentDir, "learners_config.yml") | ||
|
||
learners_config = {} | ||
|
||
try: | ||
with open(config_file, "r") as stream: | ||
learners_config = yaml.safe_load(stream) | ||
except Exception as err: | ||
print(err) | ||
|
||
users = learners_config.get("users") | ||
|
||
for user, _ in users.items(): | ||
for contentType in ["documentation", "exercises"]: | ||
|
||
# render hugo content | ||
command = "hugo" | ||
baseUrl = f"-b /{contentType}" | ||
publishDir = f"-d {outputDir}/{contentType}/{user}" | ||
contentDir = f"-c {contentBaseDir}/content/{contentType}" | ||
if contentType == "documentation": | ||
config = f"--config {contentBaseDir}/base_config.yaml,{contentBaseDir}/docu_config.yaml" | ||
else: | ||
config = f"--config {contentBaseDir}/base_config.yaml,{contentBaseDir}/{contentType}_config.yaml" | ||
themesDir = f"--themesDir {contentBaseDir}/themes/" | ||
clean = "--cleanDestinationDir" | ||
|
||
print("-" * 100) | ||
print(f"Rendering hugo content for user: {user} ...") | ||
|
||
command = f"{command} {config} {baseUrl} {publishDir} {contentDir} {themesDir} {clean}" | ||
os.system(command) | ||
|
||
print(f"Rendered content: {publishDir}") | ||
print("-" * 100 + "\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1:]) |