diff --git a/Dockerfile b/Dockerfile index 40f34a4..3c3bb5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ # docker run -it -v $(pwd)/public:/app/public dndmusicbot-js-build FROM node:19-alpine3.16 +RUN mkdir /public && chmod 777 /public + WORKDIR /app -RUN yarn - ENTRYPOINT ["yarn"] diff --git a/Makefile b/Makefile index 48a9012..baaa8c1 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,11 @@ APPLICATION_NAME ?= dndmusicbot CURRENT_UID := $(shell id -u) BIN := src/node_modules/.bin +YARN = docker run --rm --user $(CURRENT_UID) -v $(CURDIR)/src:/app -v $(CURDIR)/public:/public dndmusicbot-js-build -PHONY: js image build +PHONY: js image build clean -js: src/public/script.js +js: image public/script.js image: .jsimage @@ -13,14 +14,20 @@ image: .jsimage @docker build -t dndmusicbot-js-build . @touch .jsimage +src/node_modules: + mkdir -p $@ + src/yarn.lock: src/node_modules src/package.json - @docker run --rm --user $(CURRENT_UID) -v $(CURDIR)/src:/app dndmusicbot-js-build install --production=false --check-files + $(YARN) @touch -mr $(shell ls -Atd $? | head -1) $@ -src/public/script.js: src/script.js src/yarn.lock - @docker run --user $(CURRENT_UID) -v $(CURDIR)/src:/app dndmusicbot-js-build build +public/script.js: src/script.js src/yarn.lock + $(YARN) build $(APPLICATION_NAME): *.go ffmpeg/*.go speaker/*.go @go build build: image js $(APPLICATION_NAME) + +clean: + rm -r public/* src/node_modules .jsimage $(APPLICATION_NAME) diff --git a/routes.go b/routes.go index 097a996..4417393 100644 --- a/routes.go +++ b/routes.go @@ -22,7 +22,7 @@ func init() { app.router.GET("/play/:playlist", app.Play) app.router.GET("/reset", app.Reset) - app.router.ServeFiles("/js/*filepath", http.Dir("src/public")) + app.router.ServeFiles("/js/*filepath", http.Dir("public")) app.router.ServeFiles("/css/*filepath", http.Dir("css")) app.router.HandlerFunc("GET", "/ws", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/src/package.json b/src/package.json index 474d185..5e65b04 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "esbuild script.js --bundle --outdir=public/" + "build": "esbuild script.js --bundle --outdir=/public/" }, "dependencies": { "esbuild": "^0.15.14",