Compare commits

...

2 Commits

Author SHA1 Message Date
58c1571dbd
Update lnplay 2024-02-09 11:14:15 -05:00
276ae3a545
Add some lnplaylive-frontend code to ss 2024-02-09 11:13:43 -05:00
6 changed files with 160 additions and 2 deletions

2
lnplay

@ -1 +1 @@
Subproject commit 178d03c01dbb17e8fe5b9fd47040a79758dc4075
Subproject commit 08712283546306fd3a308ba065468a7e06c491f4

View File

@ -34,7 +34,7 @@ DEFAULT_DB_IMAGE="mariadb:10.11.2-jammy"
# run the docker stack.
export GHOST_IMAGE="ghost:5.75.1"
export GHOST_IMAGE="ghost:5.78.0"
# TODO switch to mysql. May require intricate export work for existing sites.
# THIS MUST BE COMPLETED BEFORE v1 RELEASE

1
www/lnplaylive-frontend/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

View File

@ -0,0 +1,10 @@
ARG BASE_IMAGE
FROM $BASE_IMAGE
RUN mkdir /lnplaylive
COPY app/ /lnplaylive
WORKDIR /lnplaylive
EXPOSE 5173
ENV HOST=0.0.0.0
ENV PORT 5173
RUN npm i
RUN npm run build

View File

@ -0,0 +1,48 @@
#!/bin/bash
set -exu
cd "$(dirname "$0")"
# this is the default case when a .env doesn't exist. We stub it out.
if [ "$CLN_COUNT" -gt 0 ] && [ -z "$LNPLAYLIVE_FRONTEND_ENV" ]; then
# before I can do any of this, I need to stub out the .env file...
# in order to do that, the lightning nodes need to be up first.
LNPLAYLIVE_FRONTEND_ENV="$(pwd)/.env"
PUBLIC_ADDRESS="$(bash -c "../../get_node_uri.sh --id=0 --port=$STARTING_WEBSOCKET_PORT")"
PUBLIC_WEBSOCKET_PROXY="$(echo "$PUBLIC_ADDRESS" | grep -o '@.*')"
WS_PROTO=ws
if [ "$ENABLE_TLS" = true ]; then
WS_PROTO=wss
fi
PUBLIC_RUNE=$(bash -c "../../lightning-cli.sh --id=0 commando-rune restrictions='[[\"method^lnplaylive\",\"method=waitinvoice\",\"rate=120\"]]'" | jq -r '.rune')
cat > "$LNPLAYLIVE_FRONTEND_ENV" <<EOF
PUBLIC_ADDRESS="${PUBLIC_ADDRESS}"
PUBLIC_RUNE="${PUBLIC_RUNE}"
PUBLIC_WEBSOCKET_PROXY="${WS_PROTO}://${PUBLIC_WEBSOCKET_PROXY:1}"
EOF
fi
if [ -f "$LNPLAYLIVE_FRONTEND_ENV" ]; then
cp "$LNPLAYLIVE_FRONTEND_ENV" "$(pwd)/app/.env"
# build the base image for cln
if ! docker image inspect "$LNPLAYLIVE_IMAGE_NAME" &>/dev/null; then
docker build -t "$LNPLAYLIVE_IMAGE_NAME" --build-arg BASE_IMAGE="${NODE_BASE_DOCKER_IMAGE_NAME}" ./
rm -rf ./app/node_modules
rm -rf ./app/.sveltekit
rm ./app/.env
fi
# and then load them back up with our freshly build version.
docker run -t -v lnplay-live:/output "$LNPLAYLIVE_IMAGE_NAME" cp -r /lnplaylive/build/ /output/
else
echo "ERROR: you are deploying the lnplaylive frontend application, but there is no .env file for it to build with! "
echo " you may need a backend deployment, or you need to define LNPLAYLIVE_FRONTEND_ENV in your config."
exit 1
fi

View File

@ -0,0 +1,99 @@
# this code was found in layers above the current dir;
# need to incorporate all this into sovereign-stack
# if we are deploying the lnplaylive frontend, we can rebuild at this point
# because it required build-time info from the deployed backend. The build script below
# will stub out those envs and rebuild the output from the app.
if [ "$DEPLOY_LNPLAYLIVE_FRONTEND" = true ]; then
env LNPLAYLIVE_FRONTEND_ENV="$LNPLAYLIVE_FRONTEND_ENV" ./lnplay/lnplaylive-frontend/build.sh
fi
if [ "$DEPLOY_LNPLAYLIVE_FRONTEND" = true ]; then
if ! docker image inspect "$NODE_BASE_DOCKER_IMAGE_NAME" &> /dev/null; then
# pull bitcoind down
docker pull -q "$NODE_BASE_DOCKER_IMAGE_NAME" >> /dev/null
fi
if ! docker volume list | grep -q "lnplay-live"; then
docker volume create lnplay-live
fi
fi
# if [ "$DEPLOY_LNPLAYLIVE_FRONTEND" = true ]; then
# cat >> "$DOCKER_COMPOSE_YML_PATH" <<EOF
# - lnplaylive-appnet
# EOF
# fi
if [ "$DEPLOY_LNPLAYLIVE_FRONTEND" = true ]; then
cat >> "$DOCKER_COMPOSE_YML_PATH" <<EOF
- lnplaylive:/lnplaylive:ro
EOF
fi
# if [ "$DEPLOY_LNPLAYLIVE_FRONTEND" = true ]; then
# cat >> "$DOCKER_COMPOSE_YML_PATH" <<EOF
# lnplaylive-appnet:
# EOF
# fi
if [ "$DEPLOY_LNPLAYLIVE_FRONTEND" = true ]; then
cat >> "$DOCKER_COMPOSE_YML_PATH" <<EOF
lnplaylive:
external: true
name: lnplay-live
EOF
fi
# this was in stub_nginx.conf
elif [ "$DEPLOY_LNPLAYLIVE_FRONTEND" = true ]; then
cat >> "$NGINX_CONFIG_PATH" <<EOF
# https server block for lnplaylive
server {
listen ${SERVICE_INTERNAL_PORT}${SSL_TAG};
server_name ${DOMAIN_NAME};
location ~ ^/order/(?<order_id>.+)$ {
autoindex off;
server_tokens off;
gzip_static on;
root /lnplaylive/build;
index 404.html;
}
location / {
autoindex off;
server_tokens off;
gzip_static on;
root /lnplaylive/build;
index index.html;
}
}
EOF
el