From 24d56f565e90f288776fec36a6701d86efb357b7 Mon Sep 17 00:00:00 2001 From: rbrooklyn <11929484+rbrooklyn@users.noreply.github.com> Date: Fri, 14 Feb 2020 16:43:58 +0000 Subject: [PATCH 1/4] Replace jq with our custom routine for mempool-config.json --- entrypoint.sh | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index eab7121b7..937b86ac2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,51 @@ -#!/bin/sh +#!/bin/bash +## Start SQL mysqld_safe& sleep 5 +## http server: nginx + +## Set up some files: cd /mempool.space/backend -rm -f mempool-config.json rm -f cache.json touch cache.json -jq -n env > mempool-config.json + +## Build mempool-config.json file ourseleves. +## We used to use jq for this but that produced output which caused bugs, +## specifically numbers were surrounded by quotes, which breaks things. +## Old command was jq -n env > mempool-config.json +## This way is more complex, but more compatible with the backend functions. + +## Define a function to allow us to easily get indexes of the = string in from the env output: +strindex() { + x="${1%%$2*}" + [[ "$x" = "$1" ]] && echo -1 || echo "${#x}" +} +## Regex to check if we have a number or not: +NumberRegEx='^[0-9]+$' +## Delete the old file, and start a new one: +rm -f mempool-config.json +echo "{" >> mempool-config.json +## For each env we add into the mempool-config.json file in one of two ways. +## Either: +## "Variable": "Value", +## if a string, or +## "Variable": Value, +## if a integer +for e in `env`; do + if [[ ${e:`strindex "$e" "="`+1} =~ $NumberRegEx ]] ; then + ## Integer add: + echo "\""${e:0:`strindex "$e" "="`}"\": "${e:`strindex "$e" "="`+1}"," >> mempool-config.json + else + ## String add: + echo "\""${e:0:`strindex "$e" "="`}"\": \""${e:`strindex "$e" "="`+1}$"\"," >> mempool-config.json + fi +done +## Take out the trailing , from the last entry. +## This means replacing the file with one that is missing the last character +echo `sed '$ s/.$//' mempool-config.json` > mempool-config.json +## And finally finish off: +echo "}" >> mempool-config.json + +## Start mempoolspace: node dist/index.js From 2b94cab04637e9a869a5e5039875bb2df2a20587 Mon Sep 17 00:00:00 2001 From: rbrooklyn <11929484+rbrooklyn@users.noreply.github.com> Date: Fri, 14 Feb 2020 16:49:14 +0000 Subject: [PATCH 2/4] Remove jq, add bash from alpine. Remove HTTP_PORT. General tidy HTTP_PORT was ignored and can be remapped by Docker anyway. Remove jq as no longer needed by entrypoint.sh Added bash as needed by entrypoint.sh --- Dockerfile | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3be11db2e..1255e120a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,8 @@ RUN mkdir /mempool.space/ COPY ./backend /mempool.space/backend/ COPY ./frontend /mempool.space/frontend/ COPY ./mariadb-structure.sql /mempool.space/mariadb-structure.sql -#COPY ./nginx.conf /mempool.space/nginx.conf -RUN apk add mariadb mariadb-client jq git nginx npm rsync +RUN apk add mariadb mariadb-client git nginx npm rsync bash RUN mysql_install_db --user=mysql --datadir=/var/lib/mysql/ RUN /usr/bin/mysqld_safe --datadir='/var/lib/mysql/'& \ @@ -32,12 +31,8 @@ ENV DB_PORT 3306 ENV DB_USER mempool ENV DB_PASSWORD mempool ENV DB_DATABASE mempool -ENV HTTP_PORT 80 ENV API_ENDPOINT /api/v1/ ENV CHAT_SSL_ENABLED false -#ENV CHAT_SSL_PRIVKEY -#ENV CHAT_SSL_CERT -#ENV CHAT_SSL_CHAIN ENV MEMPOOL_REFRESH_RATE_MS 500 ENV INITIAL_BLOCK_AMOUNT 8 ENV DEFAULT_PROJECTED_BLOCKS_AMOUNT 3 @@ -48,8 +43,6 @@ ENV BITCOIN_NODE_USER bitcoinuser ENV BITCOIN_NODE_PASS bitcoinpass ENV TX_PER_SECOND_SPAN_SECONDS 150 -#RUN echo "mysqld_safe& sleep 20 && cd /mempool.space/backend && rm -f mempool-config.json && rm -f cache.json && touch cache.json && jq -n env > mempool-config.json && node dist/index.js" > /entrypoint.sh - RUN cd /mempool.space/frontend/ && \ npm run build && \ rsync -av --delete dist/mempool/ /var/www/html/ From f8706f0a6242886587ed81d98b231756f605b847 Mon Sep 17 00:00:00 2001 From: rbrooklyn <11929484+rbrooklyn@users.noreply.github.com> Date: Fri, 14 Feb 2020 16:52:01 +0000 Subject: [PATCH 3/4] Remove index===3 checks from getStyleForProjectedBlockAtIndex --- .../blockchain-projected-blocks.component.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/frontend/src/app/blockchain-projected-blocks/blockchain-projected-blocks.component.ts b/frontend/src/app/blockchain-projected-blocks/blockchain-projected-blocks.component.ts index 0bfe5fc31..a353e9939 100644 --- a/frontend/src/app/blockchain-projected-blocks/blockchain-projected-blocks.component.ts +++ b/frontend/src/app/blockchain-projected-blocks/blockchain-projected-blocks.component.ts @@ -41,22 +41,12 @@ export class BlockchainProjectedBlocksComponent implements OnInit, OnDestroy { getStyleForProjectedBlockAtIndex(index: number) { const greenBackgroundHeight = 100 - (this.projectedBlocks[index].blockWeight / 4000000) * 100; if (window.innerWidth <= 768) { - if (index === 3) { - return { - 'top': 40 + index * 155 + 'px' - }; - } return { 'top': 40 + index * 155 + 'px', 'background': `repeating-linear-gradient(#554b45, #554b45 ${greenBackgroundHeight}%, #bd7c13 ${Math.max(greenBackgroundHeight, 0)}%, #c5345a 100%)`, }; } else { - if (index === 3) { - return { - 'right': 40 + index * 155 + 'px' - }; - } return { 'right': 40 + index * 155 + 'px', 'background': `repeating-linear-gradient(#554b45, #554b45 ${greenBackgroundHeight}%, From 404e90b0d45215174db85ffd2e74ad06152e0ddd Mon Sep 17 00:00:00 2001 From: rbrooklyn <11929484+rbrooklyn@users.noreply.github.com> Date: Fri, 14 Feb 2020 18:20:47 +0000 Subject: [PATCH 4/4] remove extra server_name line --- nginx-nossl-docker.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/nginx-nossl-docker.conf b/nginx-nossl-docker.conf index 180ab6a62..4e346ba2d 100644 --- a/nginx-nossl-docker.conf +++ b/nginx-nossl-docker.conf @@ -35,7 +35,6 @@ http { server { listen 80; listen [::]:80; - server_name docker.lan; root /var/www/html;