This commit is contained in:
cangui 2025-08-18 18:42:39 +02:00
parent 6117ab5b91
commit 9110ab9ec3
3 changed files with 21 additions and 45 deletions

View File

@ -1,19 +1,19 @@
# ----- build -----
FROM golang:1.24 AS builder
WORKDIR /src
FROM golang:1.24
WORKDIR /app
# Copie les fichiers de dépendances Go
COPY go.mod go.sum ./
RUN go mod download
# Copie tout le reste (code + web + assets)
COPY . .
# Si ton main est à la racine (main.go), garde ./ ; sinon mets le chemin du main
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/shelfy .
# ----- runtime -----
FROM alpine:3.20
# sh est présent (utile pour le "tee")
RUN adduser -D -u 10001 appuser
WORKDIR /app
COPY --from=builder /out/shelfy /app/shelfy
RUN chmod +x /app/shelfy && mkdir -p /app/data /app/upload /var/log/shelfy && chown -R appuser:appuser /app
USER appuser
ENTRYPOINT ["/bin/sh","-c","/app/shelfy 2>&1 | tee -a /var/log/shelfy/shelfy.log"]
# Build de ton binaire
RUN go build -o shelfy .
# Expose les ports nécessaires
EXPOSE 8080 2121
# Commande de lancement
CMD ["./shelfy"]

View File

@ -9,17 +9,14 @@ services:
working_dir: /app
ports:
- "8090:8080"
- "2121:2121"
- "30000-30100:30000-30100"
- "2222:2222"
- "2121:2121" # si tu gardes FTP
- "30000-30100:30000-30100" # si tu gardes FTP
- "2222:2222" # SFTP
extra_hosts:
- "dockerhost:host-gateway"
environment:
- SHELFY_DATA_DIR=/app/data
- "dockerhost:host-gateway" # accès à l'hôte depuis le conteneur
volumes:
- shelfy_upload:/app/upload
- shelfy_data:/app/data
- shelfy_logs:/var/log/shelfy
labels:
- traefik.http.routers.shelfy.middlewares=webdav-allow-methods@docker
- traefik.http.middlewares.webdav-allow-methods.headers.accesscontrolallowmethods=GET,PUT,POST,DELETE,PROPFIND,OPTIONS,LOCK,UNLOCK,HEAD
@ -28,23 +25,6 @@ services:
- 8.8.8.8
- 1.1.1.1
restart: unless-stopped
# (pas besoin d'un command ici si l'ENTRYPOINT du Dockerfile fait déjà le tee)
fail2ban:
image: crazymax/fail2ban:latest
container_name: fail2ban
network_mode: host
cap_add: [ "NET_ADMIN", "NET_RAW" ]
environment:
- TZ=Europe/Paris
- F2B_LOG_TARGET=STDOUT
- F2B_DB_PURGE_AGE=1d
volumes:
- ./fail2ban:/data
- shelfy_logs:/var/log/shelfy:ro
restart: unless-stopped
volumes:
shelfy_upload:
shelfy_data:
shelfy_logs:

View File

@ -249,14 +249,10 @@ func startHTTP() {
c.File("./web/index.html")
})
addr := ":8080" // ⚠️ si LocalAI tourne déjà sur 8080, change par ":8082"
log.Printf("[HTTP] Serveur Gin sur http://0.0.0.0%s", addr)
if err := app.Run(addr); err != nil {
log.Fatalf("[HTTP] Erreur lancement: %v", err)
}
log.Println("[HTTP] Serveur Gin sur http://0.0.0.0:8080")
_ = app.Run(":8080")
}
func main() {
// SFTP sur 2222 (root = ./upload)
go startSFTPServer(SFTPBaseDir)