diff --git a/Dockerfile b/Dockerfile index 88a66c1..9f86b67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,16 @@ WORKDIR /app COPY . . 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 +WORKDIR /themis 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 -ENTRYPOINT ["themis-server", "-db=prod.db"] \ No newline at end of file +ENTRYPOINT ["./start.sh"] \ No newline at end of file diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 95248c4..173b56e 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -59,6 +59,8 @@ func main() { 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{ { Name: "ping", @@ -298,7 +300,6 @@ func formatClaimsTable(claims []themis.Claim) string { func serve(address string) error { http.Handle("/health", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("OK")) - w.WriteHeader(http.StatusOK) })) return http.ListenAndServe(address, nil) diff --git a/fly.toml b/fly.toml index 8300501..a0a29b1 100644 --- a/fly.toml +++ b/fly.toml @@ -3,11 +3,11 @@ app = "themis" kill_signal = "SIGINT" kill_timeout = 5 - -[processes] -themis = "/usr/local/bin/themis-server" +processes = [] [env] +DISCORD_APP_ID = "1014881815921705030" +DISCORD_GUILD_ID = "1014883118764806164" [experimental] allowed_public_ports = [] @@ -16,7 +16,7 @@ themis = "/usr/local/bin/themis-server" [[services]] http_checks = [] internal_port = 8080 - processes = ["themis"] + processes = ["app"] protocol = "tcp" script_checks = [] [services.concurrency] diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..86c0420 --- /dev/null +++ b/start.sh @@ -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 \ No newline at end of file