Skip to content

Commit

Permalink
use nginx as a reverse proxy and fix alter statement in migrations (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj authored Apr 12, 2024
1 parent 7e50d21 commit 4122467
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/manual-deploy-obscuro-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ jobs:
&& docker run -d -p 80:80 -p 81:81 --name ${{ github.event.inputs.testnet_type }}-OG-${{ GITHUB.RUN_NUMBER }} \
-e OBSCURO_GATEWAY_VERSION="${{ GITHUB.RUN_NUMBER }}-${{ GITHUB.SHA }}" \
${{ vars.DOCKER_BUILD_TAG_GATEWAY }} \
./wallet_extension_linux -host=0.0.0.0 -port=80 -portWS=81 -nodeHost=${{ vars.L2_RPC_URL_VALIDATOR }} \
-host=0.0.0.0 -port=8080 -portWS=81 -nodeHost=${{ vars.L2_RPC_URL_VALIDATOR }} \
-logPath=sys_out -dbType=mariaDB -dbConnectionURL="obscurouser:${{ secrets.OBSCURO_GATEWAY_MARIADB_USER_PWD }}@tcp(obscurogateway-mariadb-${{ github.event.inputs.testnet_type }}.uksouth.cloudapp.azure.com:3306)/ogdb"'
14 changes: 13 additions & 1 deletion tools/walletextension/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,22 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
# Lightweight final build stage. Includes bare minimum to start wallet extension
FROM alpine:3.18

# Install NGINX
RUN apk update && apk add nginx

# copy over the gateway executable
COPY --from=build-wallet /home/obscuro/go-obscuro/tools/walletextension/bin /home/obscuro/go-obscuro/tools/walletextension/bin

# copy over the .sql migration files
COPY --from=build-wallet /home/obscuro/go-obscuro/tools/walletextension/storage/database /home/obscuro/go-obscuro/tools/walletextension/storage/database

WORKDIR /home/obscuro/go-obscuro/tools/walletextension/bin
# copy over the NGINX configuration file
COPY --from=build-wallet /home/obscuro/go-obscuro/tools/walletextension/nginx.conf /etc/nginx/nginx.conf


# copy over the entrypoint script
COPY --from=build-wallet /home/obscuro/go-obscuro/tools/walletextension/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

13 changes: 13 additions & 0 deletions tools/walletextension/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# Start NGINX in the background
nginx &

# Start wallet_extension_linux with parameters passed to the script
/home/obscuro/go-obscuro/tools/walletextension/bin/wallet_extension_linux "$@"

# Wait for any process to exit
wait -n

# Exit with the status of the process that exited first
exit $?
27 changes: 27 additions & 0 deletions tools/walletextension/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
events {
worker_connections 4096;
}

http {
server {
listen 80;

location = / {
proxy_pass http://localhost:8080/static/; # Redirects only the root URL
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

location / {
proxy_pass http://localhost:8080; # Pass all other requests to the app
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ALTER TABLE ogdb.accounts
ADD COLUMN signature_type INT DEFAULT 0;
ALTER TABLE ogdb.accounts ADD COLUMN IF NOT EXISTS signature_type INT DEFAULT 0;

0 comments on commit 4122467

Please sign in to comment.