Skip to content

Commit 9d7939a

Browse files
authored
Merge pull request #69 from fabiante/feat/landing-page
2 parents 2b3fac0 + 02c12f2 commit 9d7939a

File tree

20 files changed

+1816
-1
lines changed

20 files changed

+1816
-1
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ jobs:
3232
- name: Build
3333
run: go build -v ./...
3434

35+
build-image:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v3
39+
- name: Build image
40+
run: docker build --target runtime .
41+
3542
test-load:
3643
runs-on: ubuntu-latest
3744
env:

Dockerfile

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
1-
# Build the application from source
1+
# This layer builds the webapp
2+
FROM node as build-webapp
3+
4+
WORKDIR /app
5+
6+
COPY webapp/package.json webapp/package-lock.json ./
7+
8+
WORKDIR webapp
9+
10+
RUN npm ci
11+
12+
COPY webapp/ ./
13+
14+
RUN npm run build
15+
16+
# This layer builds the go application
217
FROM golang:latest AS build
318

419
WORKDIR /app
520

21+
# Copy go module files to download dependencies
622
COPY go.mod go.sum ./
723
RUN go mod download
824

25+
# Copy prebuild webapp
26+
COPY --from=build-webapp /app/webapp/dist ./webapp/dist
27+
28+
# Copy go source code
929
COPY . ./
1030

31+
# Build go application
1132
RUN CGO_ENABLED=0 go build -o /persurl cli/main.go
1233

1334
FROM alpine AS runtime

api/server_routes.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66

77
"github.com/DEXPRO-Solutions-GmbH/swaggerui"
8+
"github.com/fabiante/persurl/webapp"
89
"github.com/gin-gonic/gin"
910
)
1011

@@ -18,6 +19,8 @@ func SetupRouting(r gin.IRouter, s *Server) {
1819
swaggerUI.Register(r)
1920
}
2021

22+
webapp.Register(r)
23+
2124
validDomain := validPathVar("domain", regexNamed)
2225
validName := validPathVar("name", regexNamed)
2326

webapp/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist/*
12+
!dist/.gitkeep
13+
dist-ssr
14+
*.local
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

webapp/dist/.gitkeep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This keeps the dist dir in version control.
2+
This is required because embed.go is build during tests and would fail if
3+
the dist directory would not exist.

webapp/embed.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package webapp
2+
3+
import (
4+
"embed"
5+
"io/fs"
6+
"net/http"
7+
8+
"github.com/gin-gonic/gin"
9+
)
10+
11+
//go:embed dist/*
12+
var dist embed.FS
13+
14+
func Register(r gin.IRoutes) {
15+
r.GET("/", func(ctx *gin.Context) {
16+
ctx.Redirect(http.StatusPermanentRedirect, "/webapp")
17+
})
18+
19+
subFs, err := fs.Sub(dist, "dist")
20+
if err != nil {
21+
panic(err)
22+
}
23+
24+
r.StaticFS("/webapp", http.FS(subFs))
25+
}

webapp/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<!-- TODO: Add custom icon once persurl has an icon -->
6+
<!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" />-->
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<meta name="color-scheme" content="light dark" />
9+
<title>PersURL</title>
10+
</head>
11+
<body>
12+
<div id="app"></div>
13+
<script type="module" src="/src/index.tsx"></script>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)