Clean up the project and add a docker compose file
This commit is contained in:
parent
711e4942ad
commit
24c28ac95c
9 changed files with 33 additions and 47 deletions
17
.gitignore
vendored
17
.gitignore
vendored
|
@ -1,15 +1,2 @@
|
|||
/target
|
||||
/classes
|
||||
/checkouts
|
||||
pom.xml
|
||||
pom.xml.asc
|
||||
*.jar
|
||||
*.class
|
||||
/.lein-*
|
||||
/.nrepl-port
|
||||
/.project
|
||||
|
||||
/public/book.html
|
||||
/public/comic.html
|
||||
/public/comic-covers/
|
||||
/public/book-covers/
|
||||
/data
|
||||
/covers
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
* Aaron Fischer <mail@aaron-fischer.net>
|
||||
* Michael Reutter <michael@reutter.info>
|
|
@ -1,7 +1,7 @@
|
|||
FROM golang:alpine AS build
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN GOOS=linux go build -o bdm cmd/buchdesmonats/main.go
|
||||
RUN GOOS=linux go build -o bdm src/bdm.go
|
||||
|
||||
|
||||
FROM alpine
|
||||
|
|
18
LICENSE.mkd
18
LICENSE.mkd
|
@ -1,18 +0,0 @@
|
|||
Copyright (C) 2014-2015 Aaron Fischer <mail@aaron-fischer.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
6
Makefile
6
Makefile
|
@ -1,6 +0,0 @@
|
|||
build:
|
||||
mkdir -p bin
|
||||
go build -o bin/buchdesmonats cmd/buchdesmonats/main.go
|
||||
|
||||
run:
|
||||
go run cmd/buchdesmonats/main.go
|
11
README.md
Normal file
11
README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Book of the month
|
||||
|
||||
## Deploy
|
||||
|
||||
$ docker-compose build
|
||||
$ docker-compose up -d
|
||||
|
||||
## Authors
|
||||
|
||||
* Aaron Fischer <mail@aaron-fischer.net>
|
||||
* Michael Reutter <michael@reutter.info>
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
webservice:
|
||||
build: .
|
||||
image: bdm:latest
|
||||
restart: always
|
||||
volumes:
|
||||
- ./data:/app/covers
|
||||
ports:
|
||||
- 127.0.0.1:9783:9783
|
||||
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
|||
module okoyono.de/buchdesmonats
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
|
|
@ -57,14 +57,14 @@ func getItems(filename string) []Item {
|
|||
resp, err := http.Get(url)
|
||||
|
||||
if err != nil {
|
||||
panic(filename + " is missing")
|
||||
log.Fatal(filename + " is missing")
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
panic("Can not download the file. Network problem?")
|
||||
log.Fatal("Can not download the file. Network problem?")
|
||||
}
|
||||
|
||||
re := regexp.MustCompile(`[0-9]{13}`)
|
||||
|
@ -98,13 +98,14 @@ func main() {
|
|||
fileServer := http.FileServer(http.Dir("./static"))
|
||||
http.Handle("/static/", http.StripPrefix("/static", fileServer))
|
||||
|
||||
// Images
|
||||
// Cover images
|
||||
imageServer := http.FileServer(http.Dir("./covers/"))
|
||||
http.Handle("/covers/", http.StripPrefix("/covers", imageServer))
|
||||
|
||||
// Update "Hook" /update?filename=COMIC.mkd
|
||||
http.HandleFunc("/update", func(w http.ResponseWriter, r *http.Request) {
|
||||
filename := r.URL.Query().Get("filename")
|
||||
log.Printf("Update hook triggered for %v", filename)
|
||||
|
||||
// Get all items from the git repo
|
||||
items := getItems(filename)
|
||||
|
@ -119,7 +120,6 @@ func main() {
|
|||
}
|
||||
})
|
||||
|
||||
// Spawn webserver /comic
|
||||
http.HandleFunc("/book", func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Print("/book")
|
||||
getHTML("BOOK.mkd", w)
|
||||
|
@ -129,6 +129,8 @@ func main() {
|
|||
getHTML("COMIC.mkd", w)
|
||||
})
|
||||
|
||||
// Spawn the webserver (blocking)
|
||||
log.Print("Spawn webserver on port :9783 and waiting for requests ...")
|
||||
err := http.ListenAndServe(":9783", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
Loading…
Reference in a new issue