diff --git a/Dockerfile b/Dockerfile index 8aa5093..38fca18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,13 @@ +FROM node:20-alpine AS site_builder +WORKDIR /app +COPY ./www . + +RUN npm i \ + ; npm run build \ + ; rm -rf ./static \ + ; ln -sf ./www/_site ./static + + FROM golang:1.19 WORKDIR /app @@ -8,12 +18,8 @@ ENV GOBLIN_ORIGIN_URL="http://goblin.run" ENV ORIGIN_URL="http://goblin.run" COPY . ./ -RUN cd www \ - ;make installLinux \ - ;make build \ - ;cd .. \ - ;rm -rf ./static \ - ;ln -sf ./www/dist ./static +RUN rm -rf ./static ./www +COPY --from=site_builder /app/_site ./static RUN go build -o ./goblin-api ./cmd/goblin-api diff --git a/www/.gitignore b/www/.gitignore index 75ce051..aad59f8 100644 --- a/www/.gitignore +++ b/www/.gitignore @@ -1,3 +1,3 @@ /bin/ /node_modules/ -dist +_site diff --git a/www/.nvmrc b/www/.nvmrc new file mode 100644 index 0000000..a81deba --- /dev/null +++ b/www/.nvmrc @@ -0,0 +1 @@ +v20.12.2 diff --git a/www/Makefile b/www/Makefile deleted file mode 100644 index 4cda313..0000000 --- a/www/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -.PHONY: build install clean watchStyles watchPages watch - -build: - ./bin/alvu - ./bin/tailwindcss -i ./assets/main.css -o ./dist/style.css --minify - -install: - mkdir -p ./bin - # Downloading alvu - # https://github.com/barelyhuman/alvu - curl -sf https://goblin.run/github.com/barelyhuman/alvu | PREFIX=./bin sh - chmod +x ./bin/alvu - # Downloading Tailwind CSS CLI for macOS arm64 - # https://github.com/tailwindlabs/tailwindcss/releases/latest - curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64 - chmod +x ./tailwindcss-macos-arm64 - mv tailwindcss-macos-arm64 ./bin/tailwindcss - -installLinux: - mkdir -p ./bin - # Downloading alvu - # https://github.com/barelyhuman/alvu - curl -sf https://goblin.run/github.com/barelyhuman/alvu | PREFIX=./bin sh - chmod +x ./bin/alvu - # Downloading Tailwind CSS CLI for linux amd64 - # https://github.com/tailwindlabs/tailwindcss/releases/latest - curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 - chmod +x ./tailwindcss-linux-x64 - mv tailwindcss-linux-x64 ./bin/tailwindcss - - -clean: - rm ./bin/alvu ./bin/tailwindcss - -watchStyles: - ./bin/tailwindcss -i ./assets/main.css -o ./dist/style.css --watch - -watchPages: - alvu -serve - -watch: - ${MAKE} -j4 watchPages watchStyles diff --git a/www/_data/meta.js b/www/_data/meta.js new file mode 100644 index 0000000..6392bc2 --- /dev/null +++ b/www/_data/meta.js @@ -0,0 +1,7 @@ +require("dotenv").config(); + +module.exports = function () { + return { + originUrl: process.env.GOBLIN_ORIGIN_URL || "http://goblin.run", + }; +}; diff --git a/www/pages/_layout.html b/www/_includes/layout.njk similarity index 95% rename from www/pages/_layout.html rename to www/_includes/layout.njk index 101226a..39e4055 100644 --- a/www/pages/_layout.html +++ b/www/_includes/layout.njk @@ -7,6 +7,7 @@ + Goblin