From 517dca06fd652441989be60e2125bb20aa6df216 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 16:42:51 -0400 Subject: [PATCH 1/8] Retirer references/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Peuvent être consultées ailleurs --- references/date.js | 80 ------------------------------------------ references/index.html | 35 ------------------ references/messages.js | 50 -------------------------- 3 files changed, 165 deletions(-) delete mode 100644 references/date.js delete mode 100644 references/index.html delete mode 100644 references/messages.js diff --git a/references/date.js b/references/date.js deleted file mode 100644 index 20be30c..0000000 --- a/references/date.js +++ /dev/null @@ -1,80 +0,0 @@ -document.addEventListener('DOMContentLoaded', (event) => { - startDateTime() -}); - -function startDateTime() { - setDateTime(); - setInterval(function () { - setDateTime() - }, 60000); -} - -function setDateTime() { - document.getElementById("time").innerHTML = currentTime(); - document.getElementById("date").innerHTML = currentDate(); -} - -function currentTime() { - const date = new Date(); - const hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); - const minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); - - return hours + ":" + minutes; -} - -function currentDate() { - const d = new Date(); - const day = getDayOfWeek(d.getDay()); - const date = d.getDate(); - const month = getMonth(d.getMonth()); - - return day + " " + date + " " + month; -} - -function getDayOfWeek(day) { - switch (day) { - case 0: - return "Dim"; - case 1: - return "Lun"; - case 2: - return "Mar"; - case 3: - return "Mer"; - case 4: - return "Jeu"; - case 5: - return "Ven"; - case 6: - return "Sam"; - } -} - -function getMonth(month) { - switch (month) { - case 0: - return "Jan"; - case 1: - return "Fév"; - case 2: - return "Mar"; - case 3: - return "Avr"; - case 4: - return "Mai"; - case 5: - return "Juin"; - case 6: - return "Juil"; - case 7: - return "Août"; - case 8: - return "Sep"; - case 9: - return "Oct"; - case 10: - return "Nov"; - case 11: - return "Déc"; - } -} diff --git a/references/index.html b/references/index.html deleted file mode 100644 index 1d88010..0000000 --- a/references/index.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - CMS Signage - - - - - - - - - - - -
- -
- -
- -
-
-
-
- -
-
-
- -
- - - diff --git a/references/messages.js b/references/messages.js deleted file mode 100644 index 4e00eec..0000000 --- a/references/messages.js +++ /dev/null @@ -1,50 +0,0 @@ -const VITESSE_DEFILEMENT = 20; -let elems = []; - -document.addEventListener('DOMContentLoaded', () => { - startMessages() -}); - -function startMessages() { - - fetchMessages(); - - const parent = document.getElementById("text-content"); - - setInterval(() => { - for (const child of parent.children) { - child.style.left = child.getBoundingClientRect().x - 1 + 'px'; - if (child.getBoundingClientRect().right < 0) { - parent.removeChild(child); - if (parent.childElementCount < 10) { - fetchMessages(); - } - } - } - }, VITESSE_DEFILEMENT); -} - -function fetchMessages() { - return new Promise((resolve) => { - fetch('getMessages.php') - .then(response => response.json()) - .then(json => { - Object.values(json).forEach((value) => { - addDiv(value) - }); - resolve() - }); - }); -} - -function addDiv(content) { - const parent = document.getElementById("text-content"); - const lastChild = parent.lastChild; - const elem = document.createElement("div"); - elem.appendChild(document.createTextNode(content)); - parent.appendChild(elem); - if (lastChild != null) { - elem.style.left = lastChild.getBoundingClientRect().right + 50 + "px"; - } - return elem; -} -- 2.45.2 From 72eb995bb278af624da589024e55f3b263f95fe0 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:35:49 -0400 Subject: [PATCH 2/8] Ignorer fichiers .swp --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp -- 2.45.2 From cb3a099949c7f8c4453a1f3e4088f6503172e60a Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:37:10 -0400 Subject: [PATCH 3/8] Update golang:1.16 -> 1.20.2 Tagger build phase --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4204f55..ba95cc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.16 +FROM golang:1.20.2 as build LABEL author="Victor Lacasse-Beaudoin " LABEL license="MIT" -- 2.45.2 From 8bc301f0d51c783be7278bf79fe2c239e012cd4b Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:40:15 -0400 Subject: [PATCH 4/8] =?UTF-8?q?Impl=C3=A9menter=20multistage=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seulement passer fichiers source go à build phase Copier contenu/ et static/ à /app/. Copier exécutable et rouler le serveur avec les valeurs par défaut --- Dockerfile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba95cc8..3528baa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,24 @@ LABEL repo="https://git.agecem.com/agecem/babillard" WORKDIR /go/src/app -COPY . . +COPY go.mod go.sum main.go ./ -RUN go get -d -v . && \ - go install -v . +ADD cmd/ cmd/ -CMD babillard +RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o babillard . + +# Alpine + +FROM alpine:3.17.2 + +RUN apk update && apk upgrade --no-cache + +WORKDIR /app + +ADD contenu/ contenu/ + +ADD static/ static/ + +COPY --from=build /go/src/app/babillard /usr/bin/babillard + +CMD ["babillard", "server"] -- 2.45.2 From 7cd5f751a6963c2d28b5ecb5d2e4a1d62722240a Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:40:28 -0400 Subject: [PATCH 5/8] Ajouter docker-compose.yaml --- docker-compose.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d30c6af --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +services: + server: + restart: unless-stopped + build: . + image: git.agecem.com/agecem/babillard:latest + ports: + - '8080:8080' + volumes: + - 'server-config:/app/config' + command: ['babillard', 'server', '--config', '/app/config/.babillard.yaml'] + +volumes: + server-config: -- 2.45.2 From a437b93718bf8ad32d449fc085e284e1342a2a44 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:48:42 -0400 Subject: [PATCH 6/8] Simplifier nom de volume config --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index d30c6af..1ba10be 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,8 +6,8 @@ services: ports: - '8080:8080' volumes: - - 'server-config:/app/config' + - 'config:/app/config' command: ['babillard', 'server', '--config', '/app/config/.babillard.yaml'] volumes: - server-config: + config: -- 2.45.2 From e050783866f102e10c44cefee283c716990c708e Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:49:17 -0400 Subject: [PATCH 7/8] Ajouter volume contenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contient le contenu qui était dans le dossier contenu/ lors du build --- docker-compose.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 1ba10be..31c5229 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,7 +7,9 @@ services: - '8080:8080' volumes: - 'config:/app/config' + - 'contenu:/app/contenu' command: ['babillard', 'server', '--config', '/app/config/.babillard.yaml'] volumes: config: + contenu: -- 2.45.2 From 2d352f556d03f6eb91e15782b9451c02288d0064 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 5 May 2023 17:51:08 -0400 Subject: [PATCH 8/8] Retirer Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fonctionalités déplacées vers docker-compose.yaml --- Makefile | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index fed1114..0000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# SHELL = /bin/sh - -.DEFAULT_GOAL := help - -.PHONY: help -help: ## Show this help - @egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' - -.PHONY: build -build: ## Build une image selon ./Dockerfile - docker build -t agecem/babillard:latest . -- 2.45.2