code reworked to simplify
Some checks failed
Build And Push Oracolo to Docker Hub / build-push-docker-image (push) Has been cancelled

This commit is contained in:
PastaGringo 2024-05-30 13:03:56 +00:00
parent b6b5003a8d
commit f321154b1b
3 changed files with 40 additions and 52 deletions

View file

@ -1,10 +1,16 @@
FROM node:alpine as build FROM node:alpine as build
RUN apk add --no-cache git nginx RUN apk add --no-cache git
RUN git clone https://github.com/dtonon/oracolo.git /app RUN git clone https://github.com/dtonon/oracolo.git /build
WORKDIR /app WORKDIR /build
COPY entrypoint.sh /app/ RUN npm install
COPY nginx.conf /app/ RUN npm run build
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT [ "/app/entrypoint.sh" ] FROM nginx:stable-alpine
COPY --from=build /build/dist/ /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
EXPOSE 8080/tcp EXPOSE 8080/tcp
CMD ["/usr/sbin/nginx", "-g", "daemon off;"] CMD ["/usr/sbin/nginx", "-g", "daemon off;"]

View file

@ -1,6 +1,6 @@
version: '3.8' version: '3.8'
services: services:
traefik: traefik:
image: "traefik:latest" image: "traefik:latest"
container_name: "traefik" container_name: "traefik"
@ -39,13 +39,14 @@ services:
oracolo: oracolo:
container_name: oracolo container_name: oracolo
image: pastagringo/oracolo-docker # image: pastagringo/oracolo-docker
#build: build:
# context: . context: .
environment: environment:
- NPUB=${NPUB} - NPUB=${NPUB}
- RELAYS=${RELAYS} - RELAYS=${RELAYS}
- TOP_NOTES_NB=${TOP_NOTES_NB} - TOP_NOTES_NB=${TOP_NOTES_NB}
- SHORT_CHARS_NB=${SHORT_CHARS_NB}
# ports: # ports:
# - 8080:8080 # - 8080:8080
labels: labels:
@ -55,4 +56,5 @@ services:
- "traefik.http.routers.oracolo.entrypoints=websecure" - "traefik.http.routers.oracolo.entrypoints=websecure"
- "traefik.http.routers.oracolo.tls.certresolver=selfhostedservices" - "traefik.http.routers.oracolo.tls.certresolver=selfhostedservices"
- "traefik.http.middlewares.accesscontrol.headers.customResponseHeaders.access-control-allow-origin=*" - "traefik.http.middlewares.accesscontrol.headers.customResponseHeaders.access-control-allow-origin=*"
- "traefik.http.routers.oracolo.middlewares=accesscontrol@docker" - "traefik.http.routers.oracolo.middlewares=accesscontrol@docker"

View file

@ -7,65 +7,45 @@ echo "| O || / | |/ / | O || |___ | O |";
echo "| || \ | _ / \_ | || || |"; echo "| || \ | _ / \_ | || || |";
echo "| || . \| | \ || || || |"; echo "| || . \| | \ || || || |";
echo " \___/ |__|\_||__|__|\____| \___/ |_____| \___/ "; echo " \___/ |__|\_||__|__|\____| \___/ |_____| \___/ ";
echo echo " ";
echo "Oracolo dtonon's repo: https://github.com/dtonon/oracolo" echo "Oracolo dtonon's repo: https://github.com/dtonon/oracolo"
src_index_html="/app/index.html" echo "Docker image repo: https://github.com/PastaGringo/oracolo-docker"
echo echo
echo "╭────────────────────────────╮" echo "╭───────────────────────╮"
echo "│ Docker Compose Env Vars ⤵️ │" echo "│ Docker Env Vars... ⤵️ │"
echo "╰────────────────────────────╯" echo "╰───────────────────────╯"
echo echo
printf "%-15s : %s\n" "NPUB" "$NPUB" echo "> NPUB : $NPUB"
printf "%-15s : %s\n" "RELAYS" "$RELAYS" echo "> RELAYS : $RELAYS"
printf "%-15s : %s\n" "TOP_NOTES_NB" "$TOP_NOTES_NB" echo "> TOP_NOTES : $TOP_NOTES_NB"
echo "> SHORT_CHARS : $SHORT_CHARS_NB"
echo echo
echo "╭───────────────────────────╮" echo "╭───────────────────────────╮"
echo "│ Configuring Oracolo... ⤵️ │" echo "│ Configuring Oracolo... │"
echo "╰───────────────────────────╯" echo "╰───────────────────────────╯"
src_index_html="/usr/share/nginx/html/index.html"
echo echo
echo -n "> Updating npub key with $NPUB... " echo -n "> Updating author npub key... "
sed -i "s/replace_with_your_npub/$NPUB/" $src_index_html sed -i "s/replace_with_your_npub/$NPUB/" $src_index_html
echo "✅" echo "✅"
echo -n "> Updating nostr relays with $RELAYS... " echo -n "> Updating nostr relays... "
old_relays="wss://nos.lol, wss://relay.damus.io, wss://nostr.wine" old_relays="wss://nos.lol, wss://relay.damus.io, wss://nostr.wine"
RELAYS=$(echo $RELAYS | sed 's/^"//' | sed 's/"$//') RELAYS=$(echo $RELAYS | sed 's/^"//' | sed 's/"$//')
sed -i "s|$old_relays|$RELAYS|g" $src_index_html sed -i "s|$old_relays|$RELAYS|g" $src_index_html
echo "✅" echo "✅"
echo -n "> Updating TOP_NOTE with value $TOP_NOTES_NB... " echo -n "> Updating top-notes... "
old_TOP_NOTES='name="top-notes" value="0"' old_TOP_NOTES='name="top-notes" value="0"'
TOP_NOTES="name=\"top-notes\" value=\"$TOP_NOTES_NB\"" TOP_NOTES="name=\"top-notes\" value=\"$TOP_NOTES_NB\""
sed -i "s|$old_TOP_NOTES|$TOP_NOTES|g" $src_index_html sed -i "s|$old_TOP_NOTES|$TOP_NOTES|g" $src_index_html
echo "✅" echo "✅"
echo echo -n "> Updating short-chars... "
echo "╭───────────────────────╮" old_SHORT_CHARS='name="short-chars" value="0"'
echo "│ Installing Oracolo ⤵️ │" SHORT_CHARS="name=\"short-chars\" value=\"$SHORT_CHARS_NB\""
echo "╰───────────────────────╯" sed -i "s|$old_SHORT_CHARS|$SHORT_CHARS|g" $src_index_html
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
echo "╭──────────────────────╮" echo "╭──────────────────────╮"
echo "│ Starting Nginx... 🚀 │" echo "│ Starting Nginx... 🚀 │"
echo "╰──────────────────────╯" echo "╰──────────────────────╯"
echo echo
exec "$@" exec "$@"