mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
feat: embed react dist in go executable
This commit is contained in:
parent
2a3c02d942
commit
7ff1c1d222
4 changed files with 41 additions and 9 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
frontend/node_modules
|
||||||
|
frontend/dist
|
||||||
11
Dockerfile
11
Dockerfile
|
|
@ -1,3 +1,8 @@
|
||||||
|
FROM node:18-alpine as frontend
|
||||||
|
WORKDIR /build
|
||||||
|
COPY frontend ./frontend
|
||||||
|
RUN cd frontend && yarn install && yarn build
|
||||||
|
|
||||||
FROM golang:1.20-alpine as builder
|
FROM golang:1.20-alpine as builder
|
||||||
|
|
||||||
# Move to working directory /build
|
# Move to working directory /build
|
||||||
|
|
@ -11,7 +16,8 @@ RUN go mod download
|
||||||
# Copy the code into the container
|
# Copy the code into the container
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# TODO: build react app?
|
# Copy frontend dist files into the container
|
||||||
|
COPY --from=frontend /build/frontend/dist ./frontend/dist
|
||||||
|
|
||||||
# Build the application
|
# Build the application
|
||||||
RUN go build -o main
|
RUN go build -o main
|
||||||
|
|
@ -21,8 +27,5 @@ FROM alpine as final
|
||||||
|
|
||||||
# Copy the binaries and entrypoint from the builder image.
|
# Copy the binaries and entrypoint from the builder image.
|
||||||
COPY --from=builder /build/main /bin/
|
COPY --from=builder /build/main /bin/
|
||||||
# NOTE: should not be needed - assets should be embedded in the go app
|
|
||||||
#COPY --from=builder /build/public /public/
|
|
||||||
#COPY --from=builder /build/views /views/
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/bin/main" ]
|
ENTRYPOINT [ "/bin/main" ]
|
||||||
|
|
|
||||||
24
README.md
24
README.md
|
|
@ -50,6 +50,21 @@ Go to `/frontend`
|
||||||
|
|
||||||
Follow standard LND instructions. After logging in, you will be redirected to the wrong port (8080), so manually re-open <http://localhost:5173>.
|
Follow standard LND instructions. After logging in, you will be redirected to the wrong port (8080), so manually re-open <http://localhost:5173>.
|
||||||
|
|
||||||
|
### Build and run locally
|
||||||
|
|
||||||
|
`mkdir tmp`
|
||||||
|
`go build -o main`
|
||||||
|
`cp main tmp`
|
||||||
|
`cp .env tmp`
|
||||||
|
`cd tmp`
|
||||||
|
`./main`
|
||||||
|
|
||||||
|
### Run dockerfile locally
|
||||||
|
|
||||||
|
`docker build . -t nwc-local`
|
||||||
|
|
||||||
|
`docker run --env-file .env -p 8080:8080 nwc-local`
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
`go test`
|
`go test`
|
||||||
|
|
@ -148,6 +163,7 @@ You can also contribute to our [bounty program](https://github.com/getAlby/light
|
||||||
✅ `get_balance`
|
✅ `get_balance`
|
||||||
|
|
||||||
✅ `pay_invoice`
|
✅ `pay_invoice`
|
||||||
|
|
||||||
- ⚠️ amount not supported (for amountless invoices)
|
- ⚠️ amount not supported (for amountless invoices)
|
||||||
|
|
||||||
✅ `pay_keysend`
|
✅ `pay_keysend`
|
||||||
|
|
@ -178,6 +194,7 @@ You can also contribute to our [bounty program](https://github.com/getAlby/light
|
||||||
✅ `get_balance`
|
✅ `get_balance`
|
||||||
|
|
||||||
✅ `pay_invoice`
|
✅ `pay_invoice`
|
||||||
|
|
||||||
- ⚠️ amount not supported (for amountless invoices)
|
- ⚠️ amount not supported (for amountless invoices)
|
||||||
|
|
||||||
✅ `pay_keysend`
|
✅ `pay_keysend`
|
||||||
|
|
@ -201,3 +218,10 @@ You can also contribute to our [bounty program](https://github.com/getAlby/light
|
||||||
❌ `multi_pay_invoice`
|
❌ `multi_pay_invoice`
|
||||||
|
|
||||||
❌ `multi_pay_keysend (TBC)`
|
❌ `multi_pay_keysend (TBC)`
|
||||||
|
|
||||||
|
## Node Distributions
|
||||||
|
|
||||||
|
Run NWC on your own node!
|
||||||
|
|
||||||
|
- [https://github.com/getAlby/umbrel-community-app-store](Umbrel)
|
||||||
|
- [https://github.com/horologger/nostr-wallet-connect-startos](Start9) (WIP)
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,26 @@
|
||||||
package frontend
|
package frontend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"embed"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed dist
|
||||||
|
var embeddedReactAssets embed.FS
|
||||||
|
|
||||||
func RegisterHandlers(e *echo.Echo) {
|
func RegisterHandlers(e *echo.Echo) {
|
||||||
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||||
Skipper: nil,
|
Skipper: nil,
|
||||||
// Root directory from where the static content is served.
|
// Root directory from where the static content is served.
|
||||||
Root: "frontend/dist",
|
Root: "dist",
|
||||||
// Index file for serving a directory.
|
|
||||||
// Optional. Default value "index.html".
|
|
||||||
Index: "index.html",
|
|
||||||
// Enable HTML5 mode by forwarding all not-found requests to root so that
|
// Enable HTML5 mode by forwarding all not-found requests to root so that
|
||||||
// SPA (single-page application) can handle the routing.
|
// SPA (single-page application) can handle the routing.
|
||||||
HTML5: true,
|
HTML5: true,
|
||||||
Browse: false,
|
Browse: false,
|
||||||
IgnoreBase: false,
|
IgnoreBase: false,
|
||||||
Filesystem: nil,
|
Filesystem: http.FS(embeddedReactAssets),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue