diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d7d6600 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +healthr +healthr.db diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..b9c8d26 --- /dev/null +++ b/Containerfile @@ -0,0 +1,17 @@ +FROM golang:alpine AS backend_build +WORKDIR /app + +COPY go.mod ./ +RUN go mod download + +COPY . . + +RUN go build -o /healthr + +FROM alpine:edge AS backend + +COPY --from=backend_build /healthr /healthr + +EXPOSE 8090 + +CMD [ "/healthr" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7331561 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + healthr: + build: + context: . + dockerfile: Containerfile + ports: + - 8090:8090 diff --git a/main.go b/main.go index 8c70fe7..ce6bd84 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,9 @@ package main -import "log" +import ( + "fmt" + "log" +) func main() { var db Database = &SqliteDatabase{} @@ -9,5 +12,7 @@ func main() { if err != nil { log.Fatal("There was an error initializing the database %w", err) } + + fmt.Println("Starting healthr webserver.") webServer(db) }