From 6cc6914d6452f62eaaafa24dc9e4f21923a82afe Mon Sep 17 00:00:00 2001 From: Michelle Brier Date: Mon, 20 Nov 2023 09:05:34 -0800 Subject: [PATCH 1/4] wip --- protocol-dashboard/Dockerfile | 5 ++++- protocol-dashboard/entrypoint.sh | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 protocol-dashboard/entrypoint.sh diff --git a/protocol-dashboard/Dockerfile b/protocol-dashboard/Dockerfile index 7f81a017a12..b3c8aa43dc5 100644 --- a/protocol-dashboard/Dockerfile +++ b/protocol-dashboard/Dockerfile @@ -15,11 +15,14 @@ RUN apt update && \ ENV WORKDIR /app WORKDIR ${WORKDIR} -COPY .env* index.html package.json package-lock.json tsconfig.json tsconfig.node.json vite.config.ts . +COPY .env* index.html package.json package-lock.json tsconfig.json tsconfig.node.json vite.config.ts entrypoint.sh . ADD src ./src ADD public ./public ADD scripts ./scripts ADD types ./types +RUN chmod +x ./entrypoint.sh ENV DASHBOARD_BASE_URL="/dashboard/" RUN npm install --legacy-peer-deps + +# ENTRYPOINT ["./entrypoint.sh"] diff --git a/protocol-dashboard/entrypoint.sh b/protocol-dashboard/entrypoint.sh new file mode 100644 index 00000000000..4068516312a --- /dev/null +++ b/protocol-dashboard/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +FIRST_RUN_FLAG="/.firstrun" + +# Check if the container is starting for the first time +if [ ! -f "$FIRST_RUN_FLAG" ]; then + echo "Building dist..." + npm run build:$NETWORK + + if [ $? -eq 0 ]; then + echo "Successfully built dist" + touch "$FIRST_RUN_FLAG" + else + echo "'npm run build:prod' failed with exit code $?. Exiting..." + exit 1 + fi +else + echo "dist already built" +fi + +exec npm run serve From 13f67d807cd3947affd097045048d74f43d19a33 Mon Sep 17 00:00:00 2001 From: Michelle Brier Date: Mon, 27 Nov 2023 00:14:42 -0800 Subject: [PATCH 2/4] fix --- protocol-dashboard/Dockerfile | 2 -- protocol-dashboard/entrypoint.sh | 10 +++------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/protocol-dashboard/Dockerfile b/protocol-dashboard/Dockerfile index b3c8aa43dc5..2796fc8a652 100644 --- a/protocol-dashboard/Dockerfile +++ b/protocol-dashboard/Dockerfile @@ -24,5 +24,3 @@ RUN chmod +x ./entrypoint.sh ENV DASHBOARD_BASE_URL="/dashboard/" RUN npm install --legacy-peer-deps - -# ENTRYPOINT ["./entrypoint.sh"] diff --git a/protocol-dashboard/entrypoint.sh b/protocol-dashboard/entrypoint.sh index 4068516312a..a7a1e52b0a2 100644 --- a/protocol-dashboard/entrypoint.sh +++ b/protocol-dashboard/entrypoint.sh @@ -1,17 +1,13 @@ -#!/bin/bash +#!/bin/sh -FIRST_RUN_FLAG="/.firstrun" - -# Check if the container is starting for the first time -if [ ! -f "$FIRST_RUN_FLAG" ]; then +if [ ! -d "./dist" ]; then echo "Building dist..." npm run build:$NETWORK if [ $? -eq 0 ]; then echo "Successfully built dist" - touch "$FIRST_RUN_FLAG" else - echo "'npm run build:prod' failed with exit code $?. Exiting..." + echo "'npm run build:$NETWORK' failed with exit code $?. Exiting..." exit 1 fi else From 34772a2de4cb9d99fe09ca11ea78e71d5045df75 Mon Sep 17 00:00:00 2001 From: Michelle Brier Date: Tue, 28 Nov 2023 14:37:51 -0800 Subject: [PATCH 3/4] use first run flag --- protocol-dashboard/entrypoint.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/protocol-dashboard/entrypoint.sh b/protocol-dashboard/entrypoint.sh index a7a1e52b0a2..8e215578908 100644 --- a/protocol-dashboard/entrypoint.sh +++ b/protocol-dashboard/entrypoint.sh @@ -1,11 +1,14 @@ #!/bin/sh -if [ ! -d "./dist" ]; then +FIRST_RUN_FLAG="./.firstrun" + +if [ ! -f "$FIRST_RUN_FLAG" ]; then echo "Building dist..." npm run build:$NETWORK if [ $? -eq 0 ]; then echo "Successfully built dist" + touch "$FIRST_RUN_FLAG" else echo "'npm run build:$NETWORK' failed with exit code $?. Exiting..." exit 1 From af6add480a61df3b966200fc28fe5dba21403526 Mon Sep 17 00:00:00 2001 From: Michelle Brier Date: Tue, 28 Nov 2023 18:21:37 -0800 Subject: [PATCH 4/4] move to scripts --- protocol-dashboard/Dockerfile | 4 ++-- .../{entrypoint.sh => scripts/docker-entrypoint.sh} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename protocol-dashboard/{entrypoint.sh => scripts/docker-entrypoint.sh} (100%) diff --git a/protocol-dashboard/Dockerfile b/protocol-dashboard/Dockerfile index 2796fc8a652..2ec61b82dc7 100644 --- a/protocol-dashboard/Dockerfile +++ b/protocol-dashboard/Dockerfile @@ -15,12 +15,12 @@ RUN apt update && \ ENV WORKDIR /app WORKDIR ${WORKDIR} -COPY .env* index.html package.json package-lock.json tsconfig.json tsconfig.node.json vite.config.ts entrypoint.sh . +COPY .env* index.html package.json package-lock.json tsconfig.json tsconfig.node.json vite.config.ts . ADD src ./src ADD public ./public ADD scripts ./scripts ADD types ./types -RUN chmod +x ./entrypoint.sh +RUN chmod +x ./scripts/docker-entrypoint.sh ENV DASHBOARD_BASE_URL="/dashboard/" RUN npm install --legacy-peer-deps diff --git a/protocol-dashboard/entrypoint.sh b/protocol-dashboard/scripts/docker-entrypoint.sh similarity index 100% rename from protocol-dashboard/entrypoint.sh rename to protocol-dashboard/scripts/docker-entrypoint.sh