diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5c6851f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +njump diff --git a/Dockerfile b/Dockerfile index e7d3a92..93e9fc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,13 @@ FROM node:20 as tailwindbuilder WORKDIR /app/tailwind # Copy in the project files -COPY . . +COPY --link . . # Install Tailwind CLI RUN npm install tailwindcss # Generate minified Tailwind CSS bundle -RUN npx tailwind -i tailwind.css -o tailwind-bundle.min.css --minify +RUN npx tailwind -i node_modules/tailwindcss/tailwind.css -o tailwind-bundle.min.css --minify #### Go build stage FROM golang:1.21.4 as gobuilder @@ -20,15 +20,18 @@ FROM golang:1.21.4 as gobuilder WORKDIR /app # Add necessary go files -COPY go.mod go.sum ./ +COPY --link go.mod go.sum ./ RUN go mod download -COPY . . +COPY --link . . # Copy minified Tailwind CSS bundle COPY --from=tailwindbuilder /app/tailwind/tailwind-bundle.min.css ./static/tailwind-bundle.min.css +# Generate Go codes from template files +RUN go run -mod=mod github.com/a-h/templ/cmd/templ@latest generate + # Build the go binary RUN CGO_ENABLED=0 GOOS=linux go build -o main . diff --git a/pages.go b/pages.go index 230bee4..c3b5e4b 100644 --- a/pages.go +++ b/pages.go @@ -1,4 +1,6 @@ -//go:generate tmpl bind ./... +//go:generate npm install tailwindcss +//go:generate npx tailwind -i node_modules/tailwindcss/tailwind.css -o tailwind-bundle.min.css --minify +//go:generate go run -mod=mod github.com/a-h/templ/cmd/templ@latest generate package main