init commit.
This commit is contained in:
commit
27f793e6e4
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.git/
|
||||||
|
build.sh
|
||||||
|
docker-compose.yaml
|
||||||
|
README.md
|
11
Dockerfile
Normal file
11
Dockerfile
Normal 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"]
|
16
build.sh
Executable file
16
build.sh
Executable 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
11
docker-compose.yaml
Normal 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'
|
35
main.go
Normal file
35
main.go
Normal 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
BIN
static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
Loading…
x
Reference in New Issue
Block a user