Skip to content

Commit

Permalink
Use script to replace base addresses on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
fredimachado committed Sep 28, 2023
1 parent ab3d032 commit 88cfa2a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/UI/NCafe.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM nginx:alpine
FROM nginx:1.25-alpine
WORKDIR /user/share/nginx/html
EXPOSE 80

COPY output/wwwroot .

COPY nginx.conf /etc/nginx/nginx.conf

COPY prepare-appsettings.sh /docker-entrypoint.d/
RUN chmod +x /docker-entrypoint.d/prepare-appsettings.sh

COPY output/wwwroot .
9 changes: 4 additions & 5 deletions src/UI/NCafe.Web/appspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: ncafe-web-ui

ingress:
enabled: true
path: /web
hosts:
- ncafe-dev.fredi.au
- ncafe-ui-dev.fredi.au

resources:
requests:
Expand All @@ -15,11 +14,11 @@ resources:
memory: 512Mi

environment:
- name: AdminBaseAddress
- name: ADMIN_BASE_ADDRESS
value: "https://ncafe-dev.fredi.au/admin"
- name: CashierBaseAddress
- name: CASHIER_BASE_ADDRESS
value: "https://ncafe-dev.fredi.au/cashier"
- name: BaristaBaseAddress
- name: BARISTA_BASE_ADDRESS
value: "https://ncafe-dev.fredi.au/barista"

replicaCount: 1
16 changes: 16 additions & 0 deletions src/UI/NCafe.Web/prepare-appsettings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

APPSETTINGS=/user/share/nginx/html/appsettings.json

# delete compressed (brotli/gzip) appsettings files
rm "$APPSETTINGS.br"
rm "$APPSETTINGS.gz"

# update base address value using environment variables
sed -i -E "s|(\"AdminBaseAddress\"\:) \"(.*)\"(,)?|\1 \"$ADMIN_BASE_ADDRESS\"\3|g" $APPSETTINGS
sed -i -E "s|(\"CashierBaseAddress\"\:) \"(.*)\"(,)?|\1 \"$CASHIER_BASE_ADDRESS\"\3|g" $APPSETTINGS
sed -i -E "s|(\"BaristaBaseAddress\"\:) \"(.*)\"(,)?|\1 \"$BARISTA_BASE_ADDRESS\"\3|g" $APPSETTINGS

cat $APPSETTINGS

0 comments on commit 88cfa2a

Please sign in to comment.