diff --git a/Dockerfile b/Dockerfile index e69de29..d074fa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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;"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..21c392e --- /dev/null +++ b/entrypoint.sh @@ -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 "$@" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..734bf00 --- /dev/null +++ b/nginx.conf @@ -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; + } +}