set up litestream replication

absences
William Perron 2 years ago
parent 7cdf847738
commit 14cfed1b98

@ -3,7 +3,16 @@ WORKDIR /app
COPY . . COPY . .
RUN go build -o ./bin ./cmd/... RUN go build -o ./bin ./cmd/...
FROM ubuntu:22.04 as litestream
WORKDIR /download
RUN apt update -y && apt install -y wget tar
RUN wget https://github.com/benbjohnson/litestream/releases/download/v0.3.9/litestream-v0.3.9-linux-amd64.tar.gz; \
tar -zxf litestream-v0.3.9-linux-amd64.tar.gz;
FROM ubuntu:22.04 FROM ubuntu:22.04
WORKDIR /themis
COPY --from=builder /app/bin/themis-server /usr/local/bin/themis-server COPY --from=builder /app/bin/themis-server /usr/local/bin/themis-server
COPY --from=litestream /download/litestream /usr/local/bin/litestream
COPY --from=builder /app/start.sh ./start.sh
RUN apt update -y; apt install -y ca-certificates; apt-get clean RUN apt update -y; apt install -y ca-certificates; apt-get clean
ENTRYPOINT ["themis-server", "-db=prod.db"] ENTRYPOINT ["./start.sh"]

@ -59,6 +59,8 @@ func main() {
log.Fatalln("fatal error: failed to create discord app:", err) log.Fatalln("fatal error: failed to create discord app:", err)
} }
log.Printf("connected to discord: app_id=%s, guild_id=%s\n", DISCORD_APP_ID, DISCORD_GUILD_ID)
commands := []*discordgo.ApplicationCommand{ commands := []*discordgo.ApplicationCommand{
{ {
Name: "ping", Name: "ping",
@ -298,7 +300,6 @@ func formatClaimsTable(claims []themis.Claim) string {
func serve(address string) error { func serve(address string) error {
http.Handle("/health", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { http.Handle("/health", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK")) w.Write([]byte("OK"))
w.WriteHeader(http.StatusOK)
})) }))
return http.ListenAndServe(address, nil) return http.ListenAndServe(address, nil)

@ -3,11 +3,11 @@
app = "themis" app = "themis"
kill_signal = "SIGINT" kill_signal = "SIGINT"
kill_timeout = 5 kill_timeout = 5
processes = []
[processes]
themis = "/usr/local/bin/themis-server"
[env] [env]
DISCORD_APP_ID = "1014881815921705030"
DISCORD_GUILD_ID = "1014883118764806164"
[experimental] [experimental]
allowed_public_ports = [] allowed_public_ports = []
@ -16,7 +16,7 @@ themis = "/usr/local/bin/themis-server"
[[services]] [[services]]
http_checks = [] http_checks = []
internal_port = 8080 internal_port = 8080
processes = ["themis"] processes = ["app"]
protocol = "tcp" protocol = "tcp"
script_checks = [] script_checks = []
[services.concurrency] [services.concurrency]

@ -0,0 +1,3 @@
#!/usr/bin/env bash
litestream restore -o prod.db s3://themis-database-prod/prod.db
litestream replicate -exec='themis-server -db prod.db' prod.db s3://themis-database-prod/prod.db
Loading…
Cancel
Save