This commit is contained in:
PastaGringo 2024-05-27 16:19:52 +02:00
parent 652c6da746
commit 9d7b2669bc
No known key found for this signature in database
GPG key ID: 58291E5373BF82BF
3 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,10 @@
FROM node:alpine as build
RUN apk add --no-cache git nginx
RUN git clone https://github.com/dtonon/oracolo.git /app
WORKDIR /app
COPY entrypoint.sh /app/
COPY nginx.conf /app/
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT [ "/app/entrypoint.sh" ]
EXPOSE 8080/tcp
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]

65
entrypoint.sh Normal file
View file

@ -0,0 +1,65 @@
#!/bin/sh
echo
echo "Starting oracolo..."
echo
echo "Oracolo dtonon's repo: https://github.com/dtonon/oracolo"
src_index_html="/app/index.html"
echo
echo "╭────────────────────────────╮"
echo "│ Docker Compose Env Vars ⤵️ │"
echo "╰────────────────────────────╯"
echo
printf "%-15s : %s\n" "NPUB" "$NPUB"
printf "%-15s : %s\n" "RELAYS" "$RELAYS"
printf "%-15s : %s\n" "TOP_NOTES_NB" "$TOP_NOTES_NB"
echo
echo "╭───────────────────────────╮"
echo "│ Configuring Oracolo... ⤵️ │"
echo "╰───────────────────────────╯"
echo
echo -n "> Updating npub key with $NPUB... "
sed -i "s/replace_with_your_npub/$NPUB/" $src_index_html
echo "✅"
echo -n "> Updating nostr relays with $RELAYS... "
old_relays="wss://nos.lol, wss://relay.damus.io, wss://nostr.wine"
RELAYS=$(echo $RELAYS | sed 's/^"//' | sed 's/"$//')
sed -i "s|$old_relays|$RELAYS|g" $src_index_html
echo "✅"
echo -n "> Updating TOP_NOTE with value $TOP_NOTES_NB... "
old_TOP_NOTES='name="top-notes" value="0"'
TOP_NOTES="name=\"top-notes\" value=\"$TOP_NOTES_NB\""
sed -i "s|$old_TOP_NOTES|$TOP_NOTES|g" $src_index_html
echo "✅"
echo
echo "╭───────────────────────╮"
echo "│ Installing Oracolo ⤵️ │"
echo "╰───────────────────────╯"
npm install
echo
echo ">>> done ✅"
echo
echo "╭─────────────────────╮"
echo "│ Building Oracolo ⤵️ │"
echo "╰─────────────────────╯"
npm run build
echo
echo ">>> done ✅"
echo
echo -n "> Copying Oracolo built index.html to nginx usr/share/nginx/html... "
mkdir /usr/share/nginx/html
cp /app/dist/index.html /usr/share/nginx/html
echo "✅"
echo
echo "╭────────────────────────╮"
echo "│ Configuring Nginx... ⤵️ │"
echo "╰────────────────────────╯"
echo
echo -n "> Copying default nginx.conf file... "
cp /app/nginx.conf /etc/nginx/http.d/oracolo.conf
echo "✅"
echo
echo "╭──────────────────────╮"
echo "│ Starting Nginx... 🚀 │"
echo "╰──────────────────────╯"
echo
exec "$@"

15
nginx.conf Normal file
View file

@ -0,0 +1,15 @@
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}