From 75f9292ef0d3d385cebc053d2339d989356beb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Jul 2021 09:33:05 +0200 Subject: [PATCH 1/3] Add GHA to push to docker hub. --- .github/workflows/docker.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..3e2c0319 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,36 @@ +name: Publish Docker image + +on: + push: + branches: + - master + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: paritytech/parity-bridges-ui + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From bcc8fa0d477423e81c0f7a99b4113cf3356a4c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 10 Sep 2021 16:32:37 +0200 Subject: [PATCH 2/3] Allow overriding URLs via runtime ENV. --- Dockerfile | 7 ++++++- run-nginx.sh | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 run-nginx.sh diff --git a/Dockerfile b/Dockerfile index f6c8ec37..14b5bb74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,5 +27,10 @@ WORKDIR /usr/share/nginx/html RUN rm -rf ./* # Copy static assets from builder stage COPY --from=builder /parity-bridges-ui/build . +COPY --from=builder /parity-bridges-ui/.env . + +# Fix network entrypoints and start nginx. +COPY run-nginx.sh . + # Containers run nginx with global directives and daemon off -ENTRYPOINT ["nginx", "-g", "daemon off;"] +ENTRYPOINT ["/usr/share/nginx/html/run-nginx.sh"] diff --git a/run-nginx.sh b/run-nginx.sh new file mode 100755 index 00000000..c204d5b1 --- /dev/null +++ b/run-nginx.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -xeu + +. ./.env + +JS_FILES=static/js +if [ -n "${CHAIN_1_SUBSTRATE_PROVIDER+x}" ]; then + find $JS_FILES -type f -exec sed -i "s#${REACT_APP_CHAIN_1_SUBSTRATE_PROVIDER}#${CHAIN_1_SUBSTRATE_PROVIDER}#g" {} \; +fi +if [ -n "${CHAIN_2_SUBSTRATE_PROVIDER+x}" ]; then + find $JS_FILES -type f -exec sed -i "s#${REACT_APP_CHAIN_2_SUBSTRATE_PROVIDER}#${CHAIN_2_SUBSTRATE_PROVIDER}#g" {} \; +fi + +nginx -g "daemon off;" $@ From 117c3d17eabfae19273666c477eb869dca713da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 10 Sep 2021 16:35:47 +0200 Subject: [PATCH 3/3] Remove publishing. --- .github/workflows/docker.yml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 3e2c0319..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Publish Docker image - -on: - push: - branches: - - master - release: - types: [published] - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 - with: - images: paritytech/parity-bridges-ui - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }}