Skip to content

Commit

Permalink
Added node stage to build assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilyes512 committed Oct 8, 2023
1 parent c39f382 commit d5ca9f5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 17 deletions.
22 changes: 12 additions & 10 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/kubico
/.git
/.vscode
/assets
!/assets/dist
/.dockerignore
/.editorconfig
/.env
/.gitignore
/kubico
/README.md
/Taskfile.yml
/.hadolint.yml
/.github
/dist
/assets/node_modules
.dockerignore
.editorconfig
.env
.gitignore
README.md
Taskfile.dist.yml
Taskfile.yml
.hadolint.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.task
/kubico
/dist
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
FROM node:18.18.0-bullseye AS node

WORKDIR /src/assets

COPY ./assets/package*.json .

RUN npm ci

COPY ./assets .
COPY ./templates ../templates

RUN npm run prod

FROM golang:1.21.2-bookworm AS builder

WORKDIR /src
Expand All @@ -13,6 +26,8 @@ RUN go mod download

COPY . .

COPY --from=node /src/dist dist

ARG GOARCH=amd64

RUN go generate \
Expand Down
3 changes: 1 addition & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ tasks:
--tty
--env npm_config_cache=/tmp/npmcache
--user $(id -u):$(id -g)
--volume $(pwd)/assets:/src/assets
--volume $(pwd)/templates:/src/templates
--volume $(pwd):/src
--workdir /src/assets
node:{{.NODE_TAG_VERSION}} {{.RUN_CMD}}

Expand Down
1 change: 0 additions & 1 deletion assets/dist/tailwind.css

This file was deleted.

4 changes: 2 additions & 2 deletions assets/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"dev": "NODE_ENV=development postcss src/tailwind.css -o dist/tailwind.css",
"prod": "NODE_ENV=production postcss src/tailwind.css -o dist/tailwind.css"
"dev": "NODE_ENV=development postcss src/tailwind.css -o ../dist/tailwind.css",
"prod": "NODE_ENV=production postcss src/tailwind.css -o ../dist/tailwind.css"
},
"devDependencies": {
"@fullhuman/postcss-purgecss": "^5.0.0",
Expand Down
4 changes: 2 additions & 2 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"net/http"
)

//go:embed assets/dist/*
//go:embed dist/*
var assets embed.FS

func (app *application) routes() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("/", app.maxRequests(app.home))

assetsFS, err := fs.Sub(assets, "assets/dist")
assetsFS, err := fs.Sub(assets, "dist")
if err != nil {
app.errorLog.Println(err.Error())
}
Expand Down

0 comments on commit d5ca9f5

Please sign in to comment.