-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor Dockerfile and implement new CSV handling logic
- Loading branch information
1 parent
7fd2ac2
commit 0aaed93
Showing
5 changed files
with
130 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
|
||
env: | ||
IMAGE_NAME: random-api-go | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: woodchen | ||
password: ${{ secrets.ACCESS_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: woodchen/${{ env.IMAGE_NAME }}:latest | ||
platforms: linux/amd64,linux/arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,38 @@ | ||
# 构建阶段 | ||
FROM golang:1.21 AS builder | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
# 复制 go.mod 和 go.sum 文件(如果存在) | ||
COPY go.mod go.sum* ./ | ||
|
||
# 下载依赖 | ||
RUN go mod download | ||
|
||
# 复制源代码 | ||
COPY . . | ||
|
||
# 构建应用 | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o random-api . | ||
|
||
# 运行阶段 | ||
FROM alpine:latest | ||
|
||
RUN apk --no-cache add ca-certificates tini | ||
RUN apk --no-cache add ca-certificates | ||
|
||
WORKDIR /root/ | ||
|
||
COPY --from=builder /app/random-api . | ||
COPY --from=builder /app/public ./public | ||
|
||
# 创建日志目录并设置权限 | ||
RUN mkdir -p /var/log/random-api && chmod 755 /var/log/random-api | ||
|
||
EXPOSE 5003 | ||
|
||
# 使用 tini 作为初始化系统 | ||
RUN apk add --no-cache tini | ||
ENTRYPOINT ["/sbin/tini", "--"] | ||
|
||
# 运行应用 | ||
CMD ["./random-api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
{ | ||
"pic": { | ||
"all": "https://random-api.czl.net/url/pic/all.csv", | ||
"fjht": "https://random-api.czl.net/url/pic/fjht.csv", | ||
"czlwb": "https://random-api.czl.net/url/pic/czl-website-background.csv", | ||
"truegirl": "https://random-api.czl.net/url/pic/truegirl.csv", | ||
"ecy": "https://random-api.czl.net/url/pic/ecy.csv", | ||
"ecy1": "https://random-api.czl.net/url/pic/ecy1.csv", | ||
"ecy2": "https://random-api.czl.net/url/pic/ecy2.csv" | ||
}, | ||
"video": { | ||
"all": "https://random-api.czl.net/url/video/all.csv" | ||
} | ||
"pic": { | ||
"all": "url/pic/all.csv", | ||
"fjht": "url/pic/fjht.csv", | ||
"czlwb": "url/pic/czl-website-background.csv", | ||
"truegirl": "url/pic/truegirl.csv", | ||
"ecy": "url/pic/ecy.csv", | ||
"ecy1": "url/pic/ecy1.csv", | ||
"ecy2": "url/pic/ecy2.csv" | ||
}, | ||
"video": { | ||
"all": "url/video/all.csv" | ||
} | ||
} | ||
|
Binary file not shown.