Add some lnplaylive-frontend code to ss
This commit is contained in:
parent
ba3cf94259
commit
276ae3a545
1
www/lnplaylive-frontend/.gitignore
vendored
Normal file
1
www/lnplaylive-frontend/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
10
www/lnplaylive-frontend/Dockerfile
Normal file
10
www/lnplaylive-frontend/Dockerfile
Normal 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
|
48
www/lnplaylive-frontend/build.sh
Executable file
48
www/lnplaylive-frontend/build.sh
Executable 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
|
99
www/lnplaylive-frontend/some_code.sh
Normal file
99
www/lnplaylive-frontend/some_code.sh
Normal 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
|
Loading…
Reference in New Issue
Block a user