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
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" ]
RUN apk add --no-cache git
RUN git clone https://github.com/dtonon/oracolo.git /build
WORKDIR /build
RUN npm install
RUN npm run build
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
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]

View file

@ -1,6 +1,6 @@
version: '3.8'
services:
services:
traefik:
image: "traefik:latest"
container_name: "traefik"
@ -39,13 +39,14 @@ services:
oracolo:
container_name: oracolo
image: pastagringo/oracolo-docker
#build:
# context: .
# image: pastagringo/oracolo-docker
build:
context: .
environment:
- NPUB=${NPUB}
- RELAYS=${RELAYS}
- TOP_NOTES_NB=${TOP_NOTES_NB}
- SHORT_CHARS_NB=${SHORT_CHARS_NB}
# ports:
# - 8080:8080
labels:
@ -55,4 +56,5 @@ services:
- "traefik.http.routers.oracolo.entrypoints=websecure"
- "traefik.http.routers.oracolo.tls.certresolver=selfhostedservices"
- "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 "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 "│ Docker Compose Env Vars ⤵️ │"
echo "╰────────────────────────────╯"
echo "╭───────────────────────╮"
echo "│ Docker 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 "> NPUB : $NPUB"
echo "> RELAYS : $RELAYS"
echo "> TOP_NOTES : $TOP_NOTES_NB"
echo "> SHORT_CHARS : $SHORT_CHARS_NB"
echo
echo "╭───────────────────────────╮"
echo "│ Configuring Oracolo... ⤵️ │"
echo "│ Configuring Oracolo... │"
echo "╰───────────────────────────╯"
src_index_html="/usr/share/nginx/html/index.html"
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
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"
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... "
echo -n "> Updating top-notes... "
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 -n "> Updating short-chars... "
old_SHORT_CHARS='name="short-chars" value="0"'
SHORT_CHARS="name=\"short-chars\" value=\"$SHORT_CHARS_NB\""
sed -i "s|$old_SHORT_CHARS|$SHORT_CHARS|g" $src_index_html
echo "✅"
echo
echo "╭──────────────────────╮"
echo "│ Starting Nginx... 🚀 │"
echo "╰──────────────────────╯"
echo
exec "$@"
exec "$@"