containerize and add basic setup to backend

This commit is contained in:
2025-07-16 10:13:09 +01:00
parent faabae9ee0
commit a674f5641d
11 changed files with 256 additions and 4 deletions

2
backend/.dockerignore Normal file
View File

@ -0,0 +1,2 @@
.build/
tests/

13
backend/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM golang:1.24-alpine AS build
WORKDIR /app
COPY . .
RUN go build -o nuchat fergus.molloy.xyz/nuchat
FROM scratch
WORKDIR /app
COPY --from=build /app/nuchat .
ENTRYPOINT ["/app/nuchat"]

View File

@ -1,6 +1,21 @@
build:
go build -o .build/nuchat fergus.molloy.xyz/nuchat
GO_TEST := "gotestsum --format=testname --"
dirs:
@mkdir -p .build/tests
build: dirs
go build -o .build/nuchat fergus.molloy.xyz/nuchat
run: build
./.build/nuchat
test: unit integration coverage
integration:
{{GO_TEST}} ./tests/... | tee .build/tests/integration.log
unit:
{{GO_TEST}} -race $(go list ./... | grep -v "/tests") | tee .build/tests/unit.log
coverage:
{{GO_TEST}} $(go list ./... | grep -v "/tests") -coverprofile .build/tests/coverprofile.txt | tee .build/tests/coverage.log

View File

@ -3,5 +3,5 @@ package main
import "fmt"
func main() {
fmt.Println("hello world")
fmt.Println("hello world 3")
}

View File

@ -0,0 +1,7 @@
package tests
import "testing"
func TestHello(t *testing.T) {
}