minimal go backend w/ dockerfile
This commit is contained in:
12
backend/Dockerfile
Normal file
12
backend/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM golang:1.22
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . .
|
||||
RUN go build -v -o /usr/local/bin/app ./...
|
||||
|
||||
CMD ["app"]
|
||||
21
backend/cmd/app/main.go
Normal file
21
backend/cmd/app/main.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
//"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"fmt"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func main() {
|
||||
router := mux.NewRouter()
|
||||
router.HandleFunc("/ping", ping).Methods("GET")
|
||||
|
||||
log.Fatal(http.ListenAndServe(":8080", router))
|
||||
}
|
||||
|
||||
func ping(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "pong")
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
module git.weirdcat.su/weirdcat/personal-website/src/backend
|
||||
|
||||
go 1.22.5
|
||||
|
||||
require github.com/gorilla/mux v1.8.1 // indirect
|
||||
|
||||
2
backend/go.sum
Normal file
2
backend/go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
Reference in New Issue
Block a user