init commit.

This commit is contained in:
licsber 2025-01-22 15:22:50 +08:00
commit 27f793e6e4
Signed by: licsber
GPG Key ID: 9D7FB88B13C88D84
8 changed files with 83 additions and 0 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
.git/
build.sh
docker-compose.yaml
README.md

11
Dockerfile Normal file
View File

@ -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"]

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# favicon
LOGO展示.

16
build.sh Executable file
View File

@ -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 .

11
docker-compose.yaml Normal file
View File

@ -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'

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module git.licsber.site/go/favicon
go 1.23.4

35
main.go Normal file
View File

@ -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)
}
}

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB