Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions 40-env-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#! /bin/bash

if [ -z "$API_URL" ]

then
echo No API Environment Variable Set. Set "-e API_URL='your-server.tld'" in your Docker Config
else
if [ -f /api_set ]
then
echo API URL Already set to $API_URL
else
echo Setting API URL to: $API_URL
sed -i "s#var apiUrl = defaultUrl#const apiUrl = '$API_URL'#" /usr/share/nginx/html/js/ide.js
Copy link

@PhilipJonasFranz PhilipJonasFranz Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line causes runtime errors since the variable apiUrl is re-assigned within ide.js. To fix this, replace the const keyword with var.

Also, it seems like the defaultUrl variable is still used in some places. A possible fix would be to also replace this line in the code to a hard-coded value. Same goes for the extraApiUrl variable.


echo Disabling messages from public Judge CE API
sed -i "s^loadMessages();^^1" /usr/share/nginx/html/js/ide.js

touch /api_set
fi
fi
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM nginx
ADD 40-env-update.sh /docker-entrypoint.d
RUN chmod +x /docker-entrypoint.d/40-env-update.sh
COPY . /usr/share/nginx/html