From 8aa314bdb3952043bfc6d47c84b1c4a6f62c5597 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 28 Sep 2024 23:00:18 +0700 Subject: [PATCH 01/10] feat: go backend --- Dockerfile | 4 ++-- html/about.html | 4 ++-- html/index.html | 4 ++-- html/resume.html | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 975cfad..7a81673 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM docker.io/golang:1.23 as build +FROM docker.io/golang:1.23 as app COPY src/ . RUN printf 'module yw5n\ngo 1.23' > go.mod && CGO_ENABLED=0 go build -o /app FROM scratch -COPY --from=build /app /app +COPY --from=app /app /app COPY static/ /static/ COPY html/ /html/ EXPOSE 3000 diff --git a/html/about.html b/html/about.html index 9ff6258..43bbf4c 100644 --- a/html/about.html +++ b/html/about.html @@ -9,14 +9,14 @@
diff --git a/html/index.html b/html/index.html index c0b9e9c..d5b9900 100644 --- a/html/index.html +++ b/html/index.html @@ -9,7 +9,7 @@
diff --git a/html/resume.html b/html/resume.html index e42e9c1..dccbfd4 100644 --- a/html/resume.html +++ b/html/resume.html @@ -9,7 +9,7 @@ -- 2.45.2 From 87820c727ae1df2963216b679f99a419735357ff Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 28 Sep 2024 23:02:02 +0700 Subject: [PATCH 02/10] fix: auto https protocol in href --- html/about.html | 4 ++-- html/index.html | 4 ++-- html/resume.html | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/html/about.html b/html/about.html index 43bbf4c..9ff6258 100644 --- a/html/about.html +++ b/html/about.html @@ -9,14 +9,14 @@
diff --git a/html/index.html b/html/index.html index d5b9900..c0b9e9c 100644 --- a/html/index.html +++ b/html/index.html @@ -9,7 +9,7 @@
diff --git a/html/resume.html b/html/resume.html index dccbfd4..e42e9c1 100644 --- a/html/resume.html +++ b/html/resume.html @@ -9,7 +9,7 @@ -- 2.45.2 From ea10ccc31af71b4cc43f3571878a234bbbd9e36f Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 28 Sep 2024 23:15:27 +0700 Subject: [PATCH 03/10] fix: Dockerfile stages name --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7a81673..975cfad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM docker.io/golang:1.23 as app +FROM docker.io/golang:1.23 as build COPY src/ . RUN printf 'module yw5n\ngo 1.23' > go.mod && CGO_ENABLED=0 go build -o /app FROM scratch -COPY --from=app /app /app +COPY --from=build /app /app COPY static/ /static/ COPY html/ /html/ EXPOSE 3000 -- 2.45.2 From d1d304baaeecbd121562236a9c6e65a5457c363a Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 28 Sep 2024 23:19:11 +0700 Subject: [PATCH 04/10] fix: remove unused go vars --- src/vars/vars.go | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 src/vars/vars.go diff --git a/src/vars/vars.go b/src/vars/vars.go deleted file mode 100644 index 5108d04..0000000 --- a/src/vars/vars.go +++ /dev/null @@ -1,19 +0,0 @@ -package vars - -import ( - "path/filepath" -) - -var ( - templates string - static string - html string - css string -) - -func init() { - templates = "templates" - static = "static" - html = filepath.Join(static, "html") - css = filepath.Join(static, "css") -} -- 2.45.2 From 8eacf95dcb3aab40af954bb2842c0246bc483ea5 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 16 Oct 2024 14:10:18 +0800 Subject: [PATCH 05/10] feat: variable go version --- Dockerfile | 10 +++++++--- html/resume.html | 2 +- src/main.go => main.go | 0 3 files changed, 8 insertions(+), 4 deletions(-) rename src/main.go => main.go (100%) diff --git a/Dockerfile b/Dockerfile index 975cfad..ec58930 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ -FROM docker.io/golang:1.23 as build -COPY src/ . -RUN printf 'module yw5n\ngo 1.23' > go.mod && CGO_ENABLED=0 go build -o /app +ARG VER=1.23 + +FROM "docker.io/golang:$VER" as build +WORKDIR /app/ +ARG VER +COPY main.go . +RUN printf "module yw5n\ngo $VER" > go.mod && CGO_ENABLED=0 go build -o /app FROM scratch COPY --from=build /app /app diff --git a/html/resume.html b/html/resume.html index e42e9c1..836a7a7 100644 --- a/html/resume.html +++ b/html/resume.html @@ -40,7 +40,7 @@

EPITECH Toulouse - Promo 2026

  • C/C++ (system programming, AI, ciphering, games)
  • -
  • Free languages (maths, functional programming)
  • +
  • Free languages (math, functional programming)
  • DevOps (GitHub Actions, Docker, Ansible, Kubernetes)
diff --git a/src/main.go b/main.go similarity index 100% rename from src/main.go rename to main.go -- 2.45.2 From 25b1d70b89f7a0b6d27d56edb112fc39777cd051 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 16 Oct 2024 15:21:03 +0800 Subject: [PATCH 06/10] fix: docker path --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ec58930..30838d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG VER=1.23 FROM "docker.io/golang:$VER" as build -WORKDIR /app/ +WORKDIR /build/ ARG VER COPY main.go . RUN printf "module yw5n\ngo $VER" > go.mod && CGO_ENABLED=0 go build -o /app -- 2.45.2 From 805d417a9a9ca052cd46cf15576e17f6455eae40 Mon Sep 17 00:00:00 2001 From: ange Date: Tue, 19 Nov 2024 10:16:15 +0000 Subject: [PATCH 07/10] fix: dates --- html/resume.html | 4 ++-- main.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/html/resume.html b/html/resume.html index 836a7a7..87e62ce 100644 --- a/html/resume.html +++ b/html/resume.html @@ -46,13 +46,13 @@

EXPERIENCE

Freelance - DevOps

- SEPTEMBER 2023 - Today + SEPTEMBER 2023 - TODAY
  • Server setup (Debian, Docker/K8s, web server, customer application)
  • CI/CD, real-time monitoring

EPITECH CodingClub association, Toulouse - Cobra

- JANUARY 2021 - TODAY + JANUARY 2021 - JUNE 2024
  • Coding workshops for high school students
diff --git a/main.go b/main.go index e5309d1..293565e 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "log" "net/http" "path/filepath" - "strings" ) func html(w http.ResponseWriter, r *http.Request) { @@ -12,7 +11,7 @@ func html(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, "/html/style.css") return } - if strings.HasPrefix(r.URL.Path, "/static/") { + if len(r.URL.Path) > len("/static/") && r.URL.Path[:len("/static/")] == "/static/" { http.ServeFile(w, r, r.URL.Path) return } -- 2.45.2 From aaac5d780bba70f86f58188b5e7f5b5ec06e2d8a Mon Sep 17 00:00:00 2001 From: ange Date: Tue, 10 Dec 2024 03:04:52 +0000 Subject: [PATCH 08/10] 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 @@