diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6708bda --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.idea +.cache +.vscode diff --git a/Dockerfile b/Dockerfile index 5e0205b..e00afcf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,16 @@ -FROM golang:1.23.2 +FROM golang:1.23.2 AS builder WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN go get -d -v ./ -RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o ghproxy . +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ghproxy -ldflags="-s -w" . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates curl grep +ENV TZ=Asia/Shanghai +WORKDIR /app +COPY --from=builder /app/ghproxy /app/ghproxy +COPY --from=builder /app/public /app/public +COPY --from=builder /app/config.json /app/config.json EXPOSE 45000 -CMD ["./ghproxy"] \ No newline at end of file +ENTRYPOINT ["/app/ghproxy"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 70b78cf..65f4b4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,11 @@ version: '3.8' - services: - mirrors: - image: registry.cn-hangzhou.aliyuncs.com/oopsunix/ghproxy:latest - # image: oopsunix/ghproxy:latest + ghproxy: + image: oopsunix/ghproxy:latest # image:ghcr.io/oopsunix/ghproxy:latest + # image: registry.cn-hangzhou.aliyuncs.com/oopsunix/ghproxy:latest container_name: ghproxy restart: unless-stopped volumes: - - ./config.json:/app/config.json + - ./data:/app network_mode: host \ No newline at end of file