Add makefile, clean up some docker stuff

makefile
Stein Ivar Berghei 2022-11-21 00:37:49 +01:00
parent ddf24071b0
commit 27032d75a5
7 changed files with 23 additions and 9 deletions

3
.gitignore vendored
View File

@ -10,8 +10,9 @@ js/*.min.js
cache cache
bin bin
ambiance/*.mp3 ambiance
*.yml *.yml
public/ public/
node_modules/ node_modules/
src/node_modules

View File

@ -4,8 +4,6 @@ FROM node:19-alpine3.16
WORKDIR /app WORKDIR /app
COPY . /app
RUN yarn RUN yarn
ENTRYPOINT ["yarn", "build"] ENTRYPOINT ["yarn"]

15
Makefile Normal file
View File

@ -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

View File

@ -22,7 +22,7 @@ func init() {
app.router.GET("/play/:playlist", app.Play) app.router.GET("/play/:playlist", app.Play)
app.router.GET("/reset", app.Reset) 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.ServeFiles("/css/*filepath", http.Dir("css"))
app.router.HandlerFunc("GET", "/ws", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { app.router.HandlerFunc("GET", "/ws", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

View File

@ -1,6 +1,6 @@
{ {
"scripts": { "scripts": {
"build": "esbuild js/script.js --bundle --outdir=public/" "build": "esbuild script.js --bundle --outdir=public/"
}, },
"dependencies": { "dependencies": {
"esbuild": "^0.15.14", "esbuild": "^0.15.14",

View File

@ -130,11 +130,11 @@ window.onload = function () {
document.querySelector("#addambiance").addEventListener("click", (e) => { document.querySelector("#addambiance").addEventListener("click", (e) => {
e.preventDefault() e.preventDefault()
output.innerText = "" //output.innerText = ""
var title = document.querySelector("#inputambiance > input[name='title']") var title = document.querySelector("#inputambiance > input[name='title']")
var url = document.querySelector("#inputambiance > input[name='url']") var url = document.querySelector("#inputambiance > input[name='url']")
if (title.value == "" || url.value == "") { if (title.value == "" || url.value == "") {
output.innerText = "Title or Url is empty!" console.log("Title or Url is empty!")
return return
} }
@ -150,7 +150,7 @@ window.onload = function () {
submit.addEventListener("click", (e) => { submit.addEventListener("click", (e) => {
e.preventDefault() e.preventDefault()
output.innerText = "" //output.innerText = ""
var title = document.querySelector("#inputplaylist > input[name='title']") var title = document.querySelector("#inputplaylist > input[name='title']")
var url = document.querySelector("#inputplaylist > input[name='url']") var url = document.querySelector("#inputplaylist > input[name='url']")
if (title.value == "" || url.value == "") { if (title.value == "" || url.value == "") {