add Dockerfile and update fly configs

absences
William Perron 2 years ago
parent 3fdd07092e
commit 7cdf847738

@ -1 +1,9 @@
FROM nginx:latest FROM golang:1.19 as builder
WORKDIR /app
COPY . .
RUN go build -o ./bin ./cmd/...
FROM ubuntu:22.04
COPY --from=builder /app/bin/themis-server /usr/local/bin/themis-server
RUN apt update -y; apt install -y ca-certificates; apt-get clean
ENTRYPOINT ["themis-server", "-db=prod.db"]

@ -6,6 +6,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"log" "log"
"net/http"
"os" "os"
"os/signal" "os/signal"
"strconv" "strconv"
@ -216,6 +217,14 @@ func main() {
} }
log.Printf("registered %d commands\n", len(registeredCommands)) log.Printf("registered %d commands\n", len(registeredCommands))
go func() {
if err := serve(":8080"); err != nil {
log.Printf("[error]: %s\n", err)
}
cancel()
}()
<-ctx.Done() <-ctx.Done()
for _, c := range registeredCommands { for _, c := range registeredCommands {
@ -285,3 +294,12 @@ func formatClaimsTable(claims []themis.Claim) string {
} }
return sb.String() return sb.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)
}

@ -3,7 +3,9 @@
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]
@ -13,8 +15,8 @@ processes = []
[[services]] [[services]]
http_checks = [] http_checks = []
internal_port = 80 internal_port = 8080
processes = ["app"] processes = ["themis"]
protocol = "tcp" protocol = "tcp"
script_checks = [] script_checks = []
[services.concurrency] [services.concurrency]

Loading…
Cancel
Save