feat: docker

This commit is contained in:
2025-03-28 13:50:10 +01:00
parent 86801ff8e0
commit 45696fd0a9
4 changed files with 33 additions and 1 deletions

3
.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
.git
healthr
healthr.db

17
Containerfile Normal file
View File

@@ -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" ]

7
docker-compose.yml Normal file
View File

@@ -0,0 +1,7 @@
services:
healthr:
build:
context: .
dockerfile: Containerfile
ports:
- 8090:8090

View File

@@ -1,6 +1,9 @@
package main package main
import "log" import (
"fmt"
"log"
)
func main() { func main() {
var db Database = &SqliteDatabase{} var db Database = &SqliteDatabase{}
@@ -9,5 +12,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal("There was an error initializing the database %w", err) log.Fatal("There was an error initializing the database %w", err)
} }
fmt.Println("Starting healthr webserver.")
webServer(db) webServer(db)
} }