commit 27f793e6e45f2a856982ca4e03b9eaa67b02bdb3 Author: licsber Date: Wed Jan 22 15:22:50 2025 +0800 init commit. diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a85f2c3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git/ +build.sh +docker-compose.yaml +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..91aa4db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:alpine AS builder +RUN go env -w GOPROXY=https://goproxy.cn,direct + +WORKDIR /t +COPY . . +RUN go build -v -o o -ldflags="-w -s" . + +FROM alpine +COPY --from=builder /t/o /licsber +EXPOSE 4444 +ENTRYPOINT ["/licsber"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..a1af979 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# favicon + +LOGO展示. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..67e506e --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +REGISTRY='registry.cn-beijing.aliyuncs.com' +NAMESPACE='licsber' +NAME='favicon' +# 2023-01-22-1415-CST +TAG=`date +%F-%H%M-CST` + +IMAGE="$REGISTRY/$NAMESPACE/$NAME" +echo "$IMAGE:$TAG" +PLATFORM='linux/amd64,linux/arm64' +sudo docker buildx build \ + --platform $PLATFORM \ + -t "$IMAGE:$TAG" \ + -t "$IMAGE:latest" \ + --pull --push . diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..6c8c569 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,11 @@ +services: + Favicon: + build: . + image: licsber/favicon:latest + restart: always + container_name: favicon + volumes: + - /etc/localtime:/etc/localtime:ro + - /etc/timezone:/etc/timezone:ro + ports: + - '4444:4444' diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..96c3984 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.licsber.site/go/favicon + +go 1.23.4 diff --git a/main.go b/main.go new file mode 100644 index 0000000..86584c7 --- /dev/null +++ b/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "embed" + "log" + "net/http" +) + +//go:embed static/* +var fs embed.FS + +var favicon_bytes []byte + +func init() { + tmp, err := fs.ReadFile("static/favicon.ico") + if err != nil { + panic(err) + } + favicon_bytes = tmp +} + +func main() { + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + _, err := w.Write(favicon_bytes) + if err != nil { + log.Println(err) + return + } + }) + + err := http.ListenAndServe(":4444", nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..23e7e8a Binary files /dev/null and b/static/favicon.ico differ