* Update docker-compose.yml

* Update Dockerfile
This commit is contained in:
Alterem 2024-05-17 11:04:10 +08:00 committed by GitHub
parent 61903f7a7b
commit 926f4146c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 26 deletions

View File

@ -1,30 +1,17 @@
# 使用 Go 1.22 官方镜像作为构建环境
FROM golang:1.22 AS builder
FROM golang:1.21-alpine AS builder
# 禁用 CGO
ENV CGO_ENABLED=0
# 设置工作目录
WORKDIR /app
# 复制 go.mod 和 go.sum 并下载依赖
COPY go.mod go.sum ./
RUN go mod download
ADD . .
# 复制源代码并构建应用
COPY . .
RUN go build -ldflags "-s -w" -o /app/override .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o override
# 使用 Alpine Linux 作为最终镜像
FROM alpine:latest
# 设置工作目录
COPY --from=builder /app/override /usr/local/bin/override
WORKDIR /app
# 从构建阶段复制编译好的应用和资源
COPY --from=builder /app/override /app/override
ENTRYPOINT ["/usr/local/bin/override"]
# 暴露端口
EXPOSE 8080
CMD ["/app/override"]
EXPOSE 8181

View File

@ -1,9 +1,12 @@
version: '3.4'
services:
groq2api:
image: ghcr.io/linux-do/override:latest
container_name: override
override-app:
image: linux-do/override:latest
container_name: override-app
restart: always
build:
context: .
dockerfile: Dockerfile
volumes:
- ./config.json:/app/config.json
ports:
- "8181:8181"
- "8181:8181"