Skip to content

Commit

Permalink
Merge pull request #249 from wwWallet/new-workflows
Browse files Browse the repository at this point in the history
added workflows and provided a way to pass variables on run-time
  • Loading branch information
kkmanos committed May 27, 2024
2 parents fb3bc82 + 1a48c4b commit 55d7842
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 17 deletions.
30 changes: 15 additions & 15 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
HOST='0.0.0.0'
PORT=3000
REACT_APP_FIREBASE_VAPIDKEY=<Your_Vapid_Key>
REACT_APP_WS_URL=ws://wallet-backend-server:8002
REACT_APP_WALLET_BACKEND_URL=http://wallet-backend-server:8002
REACT_APP_LOGIN_WITH_PASSWORD=false
REACT_APP_FIREBASE_API_KEY=<Your_Firebase_API_Key>
REACT_APP_FIREBASE_AUTH_DOMAIN=<Your_Firebase_Auth_Domain>
REACT_APP_FIREBASE_PROJECT_ID=<Your_Firebase_Project_ID>
REACT_APP_FIREBASE_STORAGE_BUCKET=<Your_Firebase_Storage_Bucket>
REACT_APP_FIREBASE_MESSAGING_SENDER_ID=<Your_Firebase_Messaging_Sender_ID>
REACT_APP_FIREBASE_APP_ID=<Your_Firebase_App_ID>
REACT_APP_FIREBASE_MEASUREMENT_ID=<Your_Firebase_Measurement_ID>
REACT_APP_DID_KEY_VERSION=jwk_jcs-pub
HOST=VAR_HOST
PORT=VAR_PORT
REACT_APP_FIREBASE_VAPIDKEY=VAR_REACT_APP_FIREBASE_VAPIDKEY
REACT_APP_WS_URL=VAR_REACT_APP_WS_URL
REACT_APP_WALLET_BACKEND_URL=VAR_REACT_APP_WALLET_BACKEND_URL
REACT_APP_LOGIN_WITH_PASSWORD=VAR_REACT_APP_LOGIN_WITH_PASSWORD
REACT_APP_FIREBASE_API_KEY=VAR_REACT_APP_FIREBASE_API_KEY
REACT_APP_FIREBASE_AUTH_DOMAIN=VAR_REACT_APP_FIREBASE_AUTH_DOMAIN
REACT_APP_FIREBASE_PROJECT_ID=VAR_REACT_APP_FIREBASE_PROJECT_ID
REACT_APP_FIREBASE_STORAGE_BUCKET=VAR_REACT_APP_FIREBASE_STORAGE_BUCKET
REACT_APP_FIREBASE_MESSAGING_SENDER_ID=VAR_REACT_APP_FIREBASE_MESSAGING_SENDER_ID
REACT_APP_FIREBASE_APP_ID=VAR_REACT_APP_FIREBASE_APP_ID
REACT_APP_FIREBASE_MEASUREMENT_ID=VAR_REACT_APP_FIREBASE_MEASUREMENT_ID
REACT_APP_DID_KEY_VERSION=VAR_REACT_APP_DID_KEY_VERSION
REACT_APP_VERSION=$npm_package_version
REACT_APP_DISPLAY_CONSOLE=true
REACT_APP_DISPLAY_CONSOLE=VAR_REACT_APP_DISPLAY_CONSOLE
19 changes: 19 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build Docker image
on:
push:
branches-ignore:
- master
pull_request:

jobs:
build-front:
permissions:
contents: read
packages: read

uses: wwwallet/wallet-ecosystem/.github/workflows/docker-build-push.yml@master
secrets: inherit
with:
image-tag: ghcr.io/wwwallet/wallet-frontend:latest
docker-push: false
dockerfile-path: ./Dockerfile
20 changes: 20 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Push Docker image
on:
push:
tags:
- v0.*
- v1.*
- v2.*

jobs:
push-front:
permissions:
contents: read
packages: write

uses: wwwallet/wallet-ecosystem/.github/workflows/docker-build-push.yml@master
secrets: inherit
with:
image-tag: ghcr.io/wwwallet/wallet-frontend:${{ github.ref_name }}
docker-push: true
dockerfile-path: ./Dockerfile
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ src/config/config.prod.js
ssl_keys/*
*.tar.gz
.npmrc

variables.vars
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /home/node/app

# Install dependencies first so rebuild of these layers is only needed when dependencies change
COPY package.json yarn.lock .
COPY .env.template .env
RUN --mount=type=secret,id=npmrc,required=true,target=./.npmrc,uid=1000 \
yarn cache clean -f && yarn install

Expand All @@ -28,9 +29,12 @@ FROM nginx:alpine as deploy
WORKDIR /usr/share/nginx/html

COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf

COPY --from=builder /home/node/app/build/ .

COPY ./var_replacement.sh /

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
RUN chmod +x /var_replacement.sh && cat /var_replacement.sh

CMD /bin/sh /var_replacement.sh /variables.vars && nginx -g "daemon off;"
14 changes: 14 additions & 0 deletions var_replacement.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Read variables from the 'variables.vars' file and dynamically generate sed command
sed_command=""
cat /variables.vars
while IFS='=' read -r name value; do
sed_command="$sed_command s/$name/$value/g;"
done < /variables.vars


echo "Sed = $sed_command"

# Replace occurrences of variables with their corresponding values in all JavaScript files
find /usr/share/nginx/html/static/js -type f -name '*.js' -exec sed -i "$sed_command" {} +

0 comments on commit 55d7842

Please sign in to comment.