From aaac5d780bba70f86f58188b5e7f5b5ec06e2d8a Mon Sep 17 00:00:00 2001 From: ange Date: Tue, 10 Dec 2024 03:04:52 +0000 Subject: [PATCH] feat: better route function --- Dockerfile | 11 +++++---- compose.yaml | 7 ++++++ go.mod | 3 +++ go.sum | 0 html/about.html | 2 +- html/index.html | 2 +- html/resume.html | 24 +++++++++++--------- main.go | 32 -------------------------- src/main.go | 15 +++++++++++++ src/route.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 103 insertions(+), 51 deletions(-) create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 main.go create mode 100644 src/main.go create mode 100644 src/route.go diff --git a/Dockerfile b/Dockerfile index 30838d8..15c4832 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ -ARG VER=1.23 - -FROM "docker.io/golang:$VER" as build +FROM docker.io/golang:1.23 AS build WORKDIR /build/ -ARG VER -COPY main.go . -RUN printf "module yw5n\ngo $VER" > go.mod && CGO_ENABLED=0 go build -o /app +COPY go.mod go.sum . +RUN go mod download +COPY src/ . +RUN CGO_ENABLED=0 go build -o /app FROM scratch COPY --from=build /app /app diff --git a/compose.yaml b/compose.yaml index 89ab5a7..d966985 100644 --- a/compose.yaml +++ b/compose.yaml @@ -4,3 +4,10 @@ services: build: . ports: - "3000:3000" + develop: + watch: + - action: rebuild + path: src/ + - action: sync+restart + path: html/ + target: /html diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3a3a5a6 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.23.3 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/html/about.html b/html/about.html index 9ff6258..1af3590 100644 --- a/html/about.html +++ b/html/about.html @@ -8,7 +8,7 @@