Merge pull request 'Mettre à jour processus docker pour le projet' (#1) from feature/docker-compose into main
Reviewed-on: #1
This commit is contained in:
commit
be2ae3407b
7 changed files with 36 additions and 181 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.swp
|
25
Dockerfile
25
Dockerfile
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.16
|
||||
FROM golang:1.20.2 as build
|
||||
|
||||
LABEL author="Victor Lacasse-Beaudoin <vlbeaudoin@agecem.org>"
|
||||
LABEL license="MIT"
|
||||
|
@ -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"]
|
||||
|
|
11
Makefile
11
Makefile
|
@ -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 .
|
15
docker-compose.yaml
Normal file
15
docker-compose.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
services:
|
||||
server:
|
||||
restart: unless-stopped
|
||||
build: .
|
||||
image: git.agecem.com/agecem/babillard:latest
|
||||
ports:
|
||||
- '8080:8080'
|
||||
volumes:
|
||||
- 'config:/app/config'
|
||||
- 'contenu:/app/contenu'
|
||||
command: ['babillard', 'server', '--config', '/app/config/.babillard.yaml']
|
||||
|
||||
volumes:
|
||||
config:
|
||||
contenu:
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<title>CMS Signage</title>
|
||||
|
||||
<script src="js/date.js"></script>
|
||||
<script src="js/images.js"></script>
|
||||
<script src="js/messages.js"></script>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="js/style.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="contenu">
|
||||
<embed id="image"/>
|
||||
</div>
|
||||
|
||||
<div id="bar">
|
||||
|
||||
<div id="date-time">
|
||||
<div id="time"></div>
|
||||
<div id="date"></div>
|
||||
</div>
|
||||
|
||||
<div id="text-container">
|
||||
<div id="text-content"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue