Skip to content

Commit

Permalink
feat: add dockerfile, rename frontend to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
spy16 committed Jan 4, 2023
1 parent d50c7d2 commit a045219
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 5 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Build FrontEnd
FROM node:16 as fe-builder
RUN apt update -y && apt install -y golang && npm install -g vite
RUN mkdir /build
ADD ./ui /build/ui
WORKDIR /build/ui
RUN yarn && yarn build

# Build BackEnd
FROM golang:1.19-alpine3.16 as builder
RUN apk add --no-cache make
RUN mkdir /build
ADD ./ /build/
RUN rm -rf /build/ui
COPY --from=fe-builder /build/ui /build/ui
WORKDIR /build
RUN make be

# Package Staage
FROM alpine:3.11.3
COPY --from=builder /build/dist/go-svelte /app/go-svelte
COPY --from=builder /build/config.yml /app/config.yml
CMD [ "/app/go-svelte", "serve", "-c", "/app/config.yml" ]

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tidy:

fe:
@echo "Building frontend..."
@cd frontend && vite build
@cd ui && yarn && yarn build

be:
@echo "Building backend..."
Expand Down
4 changes: 2 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"gopkg.in/yaml.v2"

"github.com/saas-templates/go-svelte/api"
"github.com/saas-templates/go-svelte/frontend"
"github.com/saas-templates/go-svelte/pkg/httputils"
"github.com/saas-templates/go-svelte/pkg/log"
"github.com/saas-templates/go-svelte/ui"
)

func newCLI(ctx context.Context) *cobra.Command {
Expand Down Expand Up @@ -44,7 +44,7 @@ func cmdServe() *cobra.Command {
cfg := loadConf(cmd)

router := chi.NewRouter()
router.Mount("/", http.FileServer(http.FS(frontend.DistFS)))
router.Mount("/", http.FileServer(http.FS(ui.DistFS)))
router.Mount("/api", api.Router(cfg.API))

log.Infof(cmd.Context(), "listening at '%s'...", cfg.Addr)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/embed.go → ui/embed.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frontend
package ui

import (
"embed"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/index.html → ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AIGizmos</title>
<title>Go-Svlete</title>
<link rel="stylesheet" href="./globals.css" />
</head>
<body>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a045219

Please sign in to comment.