containerize and add basic setup to backend
This commit is contained in:
2
backend/.dockerignore
Normal file
2
backend/.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
.build/
|
||||
tests/
|
||||
13
backend/Dockerfile
Normal file
13
backend/Dockerfile
Normal 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"]
|
||||
@ -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
|
||||
|
||||
@ -3,5 +3,5 @@ package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello world")
|
||||
fmt.Println("hello world 3")
|
||||
}
|
||||
|
||||
7
backend/tests/hello_test.go
Normal file
7
backend/tests/hello_test.go
Normal file
@ -0,0 +1,7 @@
|
||||
package tests
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHello(t *testing.T) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user