initial commit
This commit is contained in:
14
backend/Dockerfile
Normal file
14
backend/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
# Build stage
|
||||
FROM golang:1.22 AS builder
|
||||
WORKDIR /app
|
||||
COPY go.mod ./
|
||||
COPY main.go ./
|
||||
RUN go mod tidy
|
||||
RUN go build -o backend main.go
|
||||
|
||||
# Run stage
|
||||
FROM debian:bookworm-slim
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/backend .
|
||||
EXPOSE 8080
|
||||
CMD ["./backend"]
|
||||
3
backend/go.mod
Normal file
3
backend/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module backend
|
||||
|
||||
go 1.22
|
||||
16
backend/main.go
Normal file
16
backend/main.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/api/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, `{"message": "Hello World from Go!"}`)
|
||||
})
|
||||
|
||||
log.Println("Backend running on :8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
Reference in New Issue
Block a user