From c8cd1d773eb3dbf8d18f8e164b10e9d3b652617f Mon Sep 17 00:00:00 2001 From: sneak Date: Tue, 24 Mar 2020 21:05:23 -0700 Subject: [PATCH] dockerize a bit more --- Dockerfile | 12 ++++++++++-- hn/server.go | 10 ++++++++-- view/about.html | 18 +++++++++++------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 00fbf1c..3ee616e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,19 @@ RUN tar cvfz go-src.tgz src && du -sh * FROM alpine -COPY --from=builder /go/src/git.eeqj.de/sneak/hntransparencylog/server /bin/server +RUN mkdir -p /app/bin + +COPY --from=builder /go/src/git.eeqj.de/sneak/hntransparencylog/server /app/bin/server +# FIXME figure out how to embed these stupid templates +COPY --from=builder /go/src/git.eeqj.de/sneak/hntransparencylog/view /app/view # put the source in there too for safekeeping COPY --from=builder /go/go-src.tgz /usr/local/src/go-src.tgz -CMD /bin/server +# this is where the db gets stored: +VOLUME /data + +WORKDIR /app +CMD /app/bin/server # FIXME add testing diff --git a/hn/server.go b/hn/server.go index 91c85e3..7a796b1 100644 --- a/hn/server.go +++ b/hn/server.go @@ -73,9 +73,15 @@ func (a *App) init() { // open db // FIXME make configurable path - db, err := gorm.Open("sqlite3", "storage.db") + DATABASE_PATH := "/data/storage.sqlite" + + if os.Getenv("DATABASE_PATH") != "" { + DATABASE_PATH = os.Getenv("DATABASE_PATH") + } + + db, err := gorm.Open("sqlite3", DATABASE_PATH) if err != nil { - panic("failed to connect database") + panic("failed to open database: " + err) } a.db = db } diff --git a/view/about.html b/view/about.html index fb108ca..50d0f5e 100644 --- a/view/about.html +++ b/view/about.html @@ -3,27 +3,31 @@ {% block content %}
-

About

-
+

About This Site

-

First Let's Get One Thing Straight

+

IMPORTANT

This is a third-party site, not affiliated with HN, provided for informational purposes only. Do not contact or hassle HN - administrators about any information you learn here.

+ administrators about any information you learn here. Their site, + their rules. I repeat: Do not hassle or interrogate the HN admins. +

Why?

I like reading stuff on the internet that is of interest to HN voters, - even if the HN administrators think it's off topic.

+ even if the HN administrators think it's off topic and don't want it on + the frontpage, which is a decision I respect. Again, their site, their + rules.

How?

Go and the - graciously-provided HN + graciously provided HN API.

-

{{ time }}

+

Who

+

@sneak.

{% endblock %}