Skip to content

Commit

Permalink
remove serving static frontend files from the gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Aug 21, 2024
1 parent 2230ad7 commit d23542e
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 94 deletions.
25 changes: 0 additions & 25 deletions tools/walletextension/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ FROM system as get-dependencies
RUN mkdir -p /home/obscuro/go-obscuro


# Install Node.js and npm (needed for frontend)
RUN apk add --update nodejs npm

# Ensures container layer caching when dependencies are not changed
WORKDIR /home/obscuro/go-obscuro
COPY go.mod .
Expand All @@ -32,21 +29,6 @@ FROM get-dependencies as build-wallet
# make sure the geth network code is available
COPY . /home/obscuro/go-obscuro

# Create .env file for frontend
WORKDIR /home/obscuro/go-obscuro/tools/walletextension/frontend
RUN if [ "$TESTNET_TYPE" = "dev-testnet" ]; then \
echo "NEXT_PUBLIC_API_GATEWAY_URL=https://dev-testnet.ten.xyz" > .env; \
elif [ "$TESTNET_TYPE" = "uat-testnet" ]; then \
echo "NEXT_PUBLIC_API_GATEWAY_URL=https://uat-testnet.ten.xyz" > .env; \
elif [ "$TESTNET_TYPE" = "sepolia-testnet" ]; then \
echo "NEXT_PUBLIC_API_GATEWAY_URL=https://testnet.ten.xyz" > .env; \
else \
echo "NEXT_PUBLIC_API_GATEWAY_URL=http://127.0.0.1:3000" > .env; \
fi
# Run npm build for frontend
RUN npm install
RUN npm run build

# build the gateway executable
WORKDIR /home/obscuro/go-obscuro/tools/walletextension/main
RUN --mount=type=cache,target=/root/.cache/go-build \
Expand All @@ -55,19 +37,12 @@ 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

# 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
Expand Down
24 changes: 0 additions & 24 deletions tools/walletextension/api/server.go

This file was deleted.

Binary file removed tools/walletextension/api/static/favicon.ico
Binary file not shown.
1 change: 0 additions & 1 deletion tools/walletextension/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const (
)

const (
PathStatic = "/static/"
PathReady = "/ready/"
PathJoin = "/join/"
PathGetMessage = "/getmessage/"
Expand Down
3 changes: 0 additions & 3 deletions tools/walletextension/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/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 "$@"

Expand Down
2 changes: 1 addition & 1 deletion tools/walletextension/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {

walletExtensionAddr := fmt.Sprintf("%s:%d", common.Localhost, config.WalletExtensionPortHTTP)
fmt.Printf("💡 Wallet extension started \n") // Some tests rely on seeing this message. Removed in next PR.
fmt.Printf("💡 Obscuro Gateway started - visit http://%s/static to use it.\n", walletExtensionAddr)
fmt.Printf("💡 Obscuro Gateway started - visit http://%s/\n", walletExtensionAddr)

select {}
}
27 changes: 0 additions & 27 deletions tools/walletextension/nginx.conf

This file was deleted.

13 changes: 0 additions & 13 deletions tools/walletextension/walletextension_container.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package walletextension

import (
"net/http"
"os"
"time"

"github.com/ten-protocol/go-ten/go/common/subscription"

"github.com/ten-protocol/go-ten/tools/walletextension/api"

"github.com/ten-protocol/go-ten/tools/walletextension/httpapi"

"github.com/ten-protocol/go-ten/tools/walletextension/rpcapi"
Expand Down Expand Up @@ -92,16 +89,6 @@ func NewContainerFromConfig(config wecommon.Config, logger gethlog.Logger) *Cont
},
})

// register the static files
// todo - remove this when the frontend is no longer served from the enclave
staticHandler := api.StaticFilesHandler(wecommon.PathStatic)
rpcServer.RegisterRoutes([]node.Route{{
Name: wecommon.PathStatic,
Func: func(resp http.ResponseWriter, req *http.Request) {
staticHandler.ServeHTTP(resp, req)
},
}})

return &Container{
stopControl: stopControl,
rpcServer: rpcServer,
Expand Down

0 comments on commit d23542e

Please sign in to comment.