diff --git a/README.md b/README.md index f8dd387..5fab159 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ **然后**,执行下面的命令或者项目中的程序(`bash pull-images.sh`),获取必要的镜像文件: ```bash -docker pull soulteary/golang-playground:web-1.19.0 -docker pull soulteary/golang-playground:sandbox-1.19.0 -docker pull soulteary/golang-playground:actuator-1.19.0 +docker pull soulteary/golang-playground:web-1.23.4 +docker pull soulteary/golang-playground:sandbox-1.23.4 +docker pull soulteary/golang-playground:actuator-1.23.4 docker pull memcached:1.6.15-alpine ``` @@ -37,22 +37,22 @@ docker pull memcached:1.6.15-alpine ```bash # bash make-images.sh Sending build context to Docker daemon 1.349MB -Step 1/30 : ARG GO_VERSION=1.19.0 -Step 2/30 : FROM golang:${GO_VERSION}-alpine3.16 AS build-playground +Step 1/30 : ARG GO_VERSION=1.23.4 +Step 2/30 : FROM golang:${GO_VERSION}-alpine3.21 AS build-playground ---> 5e999c13ceac Step 3/30 : LABEL maintainer="soulteary@gmail.com" ---> Using cache ---> a253b22ef53a ... Successfully built 37e124ce9e7f -Successfully tagged soulteary/golang-playground:web-1.19.0 +Successfully tagged soulteary/golang-playground:web-1.23.4 ... Successfully built 6017738b85ce -Successfully tagged soulteary/golang-playground:sandbox-1.19.0 -Step 1/24 : ARG GO_VERSION=1.19.0 -Step 2/24 : FROM golang:${GO_VERSION}-alpine3.16 AS build-sandbox +Successfully tagged soulteary/golang-playground:sandbox-1.23.4 +Step 1/24 : ARG GO_VERSION=1.23.4 +Step 2/24 : FROM golang:${GO_VERSION}-alpine3.21 AS build-sandbox ... Successfully built c51b8a6647fb -Successfully tagged soulteary/golang-playground:actuator-1.19.0 +Successfully tagged soulteary/golang-playground:actuator-1.23.4 ``` diff --git a/docker-compose.yml b/docker-compose.yml index a3bd8f1..e8cb6b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,9 @@ version: '3' services: sandbox: - image: soulteary/golang-playground:sandbox-1.19.0 + image: soulteary/golang-playground:sandbox-1.23.4 restart: always - command: -mode=server -listen=0.0.0.0:80 -workers=1 -untrusted-container=soulteary/golang-playground:actuator-1.19.0 + command: -mode=server -listen=0.0.0.0:80 -workers=1 -untrusted-container=soulteary/golang-playground:actuator-1.23.4 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro networks: @@ -13,7 +13,7 @@ services: - memcached web: - image: soulteary/golang-playground:web-1.19.0 + image: soulteary/golang-playground:web-1.23.4 restart: always environment: - SANDBOX_BACKEND_URL=http://sandbox:/run diff --git a/docker/Dockerfile.actuator b/docker/Dockerfile.actuator index 1098a4f..4244388 100644 --- a/docker/Dockerfile.actuator +++ b/docker/Dockerfile.actuator @@ -1,5 +1,5 @@ -ARG GO_VERSION=1.19.0 -FROM golang:${GO_VERSION}-alpine3.16 AS build-sandbox +ARG GO_VERSION=1.23.4 +FROM golang:${GO_VERSION}-alpine3.21 AS build-sandbox # base deps RUN apk update && apk add tzdata # download golang deps @@ -16,11 +16,11 @@ RUN CGO_ENABLED=0 go build -ldflags "-w -s" . -FROM alpine:3.16 AS build-actuator +FROM alpine:3.21 AS build-actuator LABEL maintainer="soulteary@gmail.com" RUN echo '' > /etc/apk/repositories && \ - echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.16/main" >> /etc/apk/repositories && \ - echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories && \ + echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.21/main" >> /etc/apk/repositories && \ + echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.21/community" >> /etc/apk/repositories && \ echo "Asia/Shanghai" > /etc/timezone RUN apk add --no-cache docker-cli COPY --from=build-sandbox /go/src/playground/sandbox/sandbox /bin/play-sandbox diff --git a/docker/Dockerfile.sandbox b/docker/Dockerfile.sandbox index 2493019..4aca75a 100644 --- a/docker/Dockerfile.sandbox +++ b/docker/Dockerfile.sandbox @@ -1,5 +1,5 @@ -ARG GO_VERSION=1.19.0 -FROM golang:${GO_VERSION}-alpine3.16 AS build-sandbox +ARG GO_VERSION=1.23.4 +FROM golang:${GO_VERSION}-alpine3.21 AS build-sandbox # base deps RUN apk update && apk add tzdata # download golang deps @@ -16,11 +16,11 @@ RUN CGO_ENABLED=0 go build -ldflags "-w -s" . -FROM alpine:3.16 +FROM alpine:3.21 LABEL maintainer="soulteary@gmail.com" RUN echo '' > /etc/apk/repositories && \ - echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.16/main" >> /etc/apk/repositories && \ - echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.16/community" >> /etc/apk/repositories && \ + echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.21/main" >> /etc/apk/repositories && \ + echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.21/community" >> /etc/apk/repositories && \ echo "Asia/Shanghai" > /etc/timezone RUN apk add --no-cache docker-cli COPY --from=build-sandbox /go/src/playground/sandbox/sandbox /bin/play-sandbox diff --git a/docker/Dockerfile.web b/docker/Dockerfile.web index 568648c..76e019f 100644 --- a/docker/Dockerfile.web +++ b/docker/Dockerfile.web @@ -1,5 +1,5 @@ -ARG GO_VERSION=1.19.0 -FROM golang:${GO_VERSION}-alpine3.16 AS build-playground +ARG GO_VERSION=1.23.4 +FROM golang:${GO_VERSION}-alpine3.21 AS build-playground LABEL maintainer="soulteary@gmail.com" # download golang deps ENV GO111MODULE=on @@ -14,7 +14,7 @@ RUN CGO_ENABLED=0 go build -ldflags "-w -s" . -FROM golang:${GO_VERSION}-alpine3.16 +FROM golang:${GO_VERSION}-alpine3.21 COPY --from=build-playground /usr/local/go /usr/local/go-faketime ENV CGO_ENABLED 0 diff --git a/make-images.sh b/make-images.sh index 3f4b008..54251ca 100755 --- a/make-images.sh +++ b/make-images.sh @@ -1,5 +1,5 @@ #!/bin/bash -docker build -t soulteary/golang-playground:web-1.19.0 -f docker/Dockerfile.web . -docker build -t soulteary/golang-playground:sandbox-1.19.0 -f docker/Dockerfile.sandbox . -docker build -t soulteary/golang-playground:actuator-1.19.0 -f docker/Dockerfile.actuator . +docker build -t soulteary/golang-playground:web-1.23.4 -f docker/Dockerfile.web . +docker build -t soulteary/golang-playground:sandbox-1.23.4 -f docker/Dockerfile.sandbox . +docker build -t soulteary/golang-playground:actuator-1.23.4 -f docker/Dockerfile.actuator . diff --git a/pull-images.sh b/pull-images.sh index 18f04e3..66d51dc 100755 --- a/pull-images.sh +++ b/pull-images.sh @@ -1,6 +1,6 @@ #!/bin/bash -docker pull soulteary/golang-playground:web-1.19.0 -docker pull soulteary/golang-playground:sandbox-1.19.0 -docker pull soulteary/golang-playground:actuator-1.19.0 +docker pull soulteary/golang-playground:web-1.23.4 +docker pull soulteary/golang-playground:sandbox-1.23.4 +docker pull soulteary/golang-playground:actuator-1.23.4 docker pull memcached:1.6.15-alpine diff --git a/src/sandbox/sandbox.go b/src/sandbox/sandbox.go index 8c33aab..8755a03 100644 --- a/src/sandbox/sandbox.go +++ b/src/sandbox/sandbox.go @@ -161,9 +161,9 @@ type dockerContainer struct { // ID is the docker container ID. ID string `json:"ID"` // Image is the docker image name. - Image string `json:"Image"` + Image string `json:"IMAGE"` // Names is the docker container name. - Names string `json:"Names"` + Names string `json:"NAMES"` } // countDockerContainers records the metric for the current number of docker containers. @@ -186,7 +186,7 @@ func countDockerContainers(ctx context.Context) { // listDockerContainers returns the current running play_run containers reported by docker. func listDockerContainers(ctx context.Context) ([]dockerContainer, error) { out := new(bytes.Buffer) - cmd := exec.Command("docker", "ps", "--quiet", "--filter", "name=play_run_", "--format", "{{json .}}") + cmd := exec.Command("docker", "ps", "--filter", "name=play_run_", "--format", "json") cmd.Stdout, cmd.Stderr = out, out if err := cmd.Start(); err != nil { return nil, fmt.Errorf("listDockerContainers: cmd.Start() failed: %w", err)