-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from getAlby/fix/embed-react
feat: embed react dist in go executable
- Loading branch information
Showing
6 changed files
with
113 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
frontend/node_modules | ||
frontend/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,55 +10,55 @@ jobs: | |
IMAGENAME: ${{ github.event.repository.name }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
name: Check out code | ||
- name: Install Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.20.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run tests | ||
run: go test | ||
- name: Docker build | ||
uses: mr-smithers-excellent/docker-build-push@v6 | ||
id: build | ||
with: | ||
image: ${{ env.IMAGENAME }} | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Checkout deployment repo | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: getalby/alby-deployment | ||
path: infrastructure | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
# Always update dev environment | ||
- name: Update dev environment | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: fjogeleit/[email protected] | ||
with: | ||
valueFile: 'alby-simnet-deployment/values.yaml' | ||
propertyPath: 'nwc.image.tag' | ||
value: ${{ steps.build.outputs.tags }} | ||
repository: getalby/alby-deployment | ||
branch: main | ||
createPR: false | ||
message: 'CD: Update nwc tag to ${{ steps.build.outputs.tags }}' | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
workDir: infrastructure | ||
# Only update prod environment if this action was triggered by a new tag | ||
- name: Update production environment | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: fjogeleit/[email protected] | ||
with: | ||
valueFile: 'alby-mainnet-deployment/values.yaml' | ||
propertyPath: 'nwc.image.tag' | ||
value: ${{ steps.build.outputs.tags }} | ||
repository: getalby/alby-deployment | ||
branch: main | ||
createPR: false | ||
message: 'CD: Update nwc tag to ${{ steps.build.outputs.tags }}' | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
workDir: infrastructure | ||
- uses: actions/checkout@v2 | ||
name: Check out code | ||
- name: Install Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.20.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run tests | ||
run: mkdir frontend/dist && touch frontend/dist/tmp && go test | ||
- name: Docker build | ||
uses: mr-smithers-excellent/docker-build-push@v6 | ||
id: build | ||
with: | ||
image: ${{ env.IMAGENAME }} | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Checkout deployment repo | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: getalby/alby-deployment | ||
path: infrastructure | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
# Always update dev environment | ||
- name: Update dev environment | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: fjogeleit/[email protected] | ||
with: | ||
valueFile: "alby-simnet-deployment/values.yaml" | ||
propertyPath: "nwc.image.tag" | ||
value: ${{ steps.build.outputs.tags }} | ||
repository: getalby/alby-deployment | ||
branch: main | ||
createPR: false | ||
message: "CD: Update nwc tag to ${{ steps.build.outputs.tags }}" | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
workDir: infrastructure | ||
# Only update prod environment if this action was triggered by a new tag | ||
- name: Update production environment | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: fjogeleit/[email protected] | ||
with: | ||
valueFile: "alby-mainnet-deployment/values.yaml" | ||
propertyPath: "nwc.image.tag" | ||
value: ${{ steps.build.outputs.tags }} | ||
repository: getalby/alby-deployment | ||
branch: main | ||
createPR: false | ||
message: "CD: Update nwc tag to ${{ steps.build.outputs.tags }}" | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
workDir: infrastructure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
package frontend | ||
|
||
import ( | ||
"embed" | ||
"net/http" | ||
|
||
"github.com/labstack/echo/v4" | ||
"github.com/labstack/echo/v4/middleware" | ||
) | ||
|
||
//go:embed dist | ||
var embeddedReactAssets embed.FS | ||
|
||
func RegisterHandlers(e *echo.Echo) { | ||
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{ | ||
Skipper: nil, | ||
// Root directory from where the static content is served. | ||
Root: "frontend/dist", | ||
// Index file for serving a directory. | ||
// Optional. Default value "index.html". | ||
Index: "index.html", | ||
Root: "dist", | ||
// Enable HTML5 mode by forwarding all not-found requests to root so that | ||
// SPA (single-page application) can handle the routing. | ||
HTML5: true, | ||
Browse: false, | ||
IgnoreBase: false, | ||
Filesystem: nil, | ||
Filesystem: http.FS(embeddedReactAssets), | ||
})) | ||
} |