From 27032d75a5ae44a94b2a461a2dcdbe35203139a7 Mon Sep 17 00:00:00 2001 From: Stein Ivar Berghei Date: Mon, 21 Nov 2022 00:37:49 +0100 Subject: [PATCH] Add makefile, clean up some docker stuff --- .gitignore | 3 ++- Dockerfile | 4 +--- Makefile | 15 +++++++++++++++ routes.go | 2 +- package.json => src/package.json | 2 +- {js => src}/script.js | 6 +++--- yarn.lock => src/yarn.lock | 0 7 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 Makefile rename package.json => src/package.json (69%) rename {js => src}/script.js (98%) rename yarn.lock => src/yarn.lock (100%) diff --git a/.gitignore b/.gitignore index f4dac66..b8cbb8a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,9 @@ js/*.min.js cache bin -ambiance/*.mp3 +ambiance *.yml public/ node_modules/ +src/node_modules diff --git a/Dockerfile b/Dockerfile index 28d6007..40f34a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,6 @@ FROM node:19-alpine3.16 WORKDIR /app -COPY . /app - RUN yarn -ENTRYPOINT ["yarn", "build"] +ENTRYPOINT ["yarn"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1bc2f29 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +APPLICATION_NAME ?= dndmusicbot +CURRENT_UID := $(shell id -u) + +default: build + +image: Dockerfile + docker build -t dndmusicbot-js-build . + touch .jsimage + +web: src/script.js + docker run --user $(CURRENT_UID) -v $(CURDIR)/src:/app dndmusicbot-js-build install + docker run --user $(CURRENT_UID) -v $(CURDIR)/src:/app dndmusicbot-js-build build + +build: *.go + go build \ No newline at end of file diff --git a/routes.go b/routes.go index 4417393..097a996 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("public")) + app.router.ServeFiles("/js/*filepath", http.Dir("src/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/package.json b/src/package.json similarity index 69% rename from package.json rename to src/package.json index b509036..474d185 100644 --- a/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "scripts": { - "build": "esbuild js/script.js --bundle --outdir=public/" + "build": "esbuild script.js --bundle --outdir=public/" }, "dependencies": { "esbuild": "^0.15.14", diff --git a/js/script.js b/src/script.js similarity index 98% rename from js/script.js rename to src/script.js index 75baa7f..e49782a 100644 --- a/js/script.js +++ b/src/script.js @@ -130,11 +130,11 @@ window.onload = function () { document.querySelector("#addambiance").addEventListener("click", (e) => { e.preventDefault() - output.innerText = "" + //output.innerText = "" var title = document.querySelector("#inputambiance > input[name='title']") var url = document.querySelector("#inputambiance > input[name='url']") if (title.value == "" || url.value == "") { - output.innerText = "Title or Url is empty!" + console.log("Title or Url is empty!") return } @@ -150,7 +150,7 @@ window.onload = function () { submit.addEventListener("click", (e) => { e.preventDefault() - output.innerText = "" + //output.innerText = "" var title = document.querySelector("#inputplaylist > input[name='title']") var url = document.querySelector("#inputplaylist > input[name='url']") if (title.value == "" || url.value == "") { diff --git a/yarn.lock b/src/yarn.lock similarity index 100% rename from yarn.lock rename to src/yarn.lock