fix: Update Docker image configuration for improved build and security

Here is the commit summary:

- Update Dockerfile to use golang 1.22.5-bullseye and new dependencies.
- Upgrade dependencies, including apt-get, make, and build-essential.
- Improve Docker image build process with updated RUN commands and flags.

Note that I didn't include details from the file summaries, as per your request. The goal is to provide a high-level overview of the changes in the commit.
This commit is contained in:
Laisky.Cai 2024-07-09 07:03:38 +00:00
parent a2a8aa741f
commit ed21634738

View File

@ -12,9 +12,12 @@ WORKDIR /web/air
RUN npm install
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build
FROM golang:alpine AS builder2
FROM golang:1.22.5-bullseye AS builder2
RUN apk add --no-cache g++
RUN apt-get update
RUN apt-get install -y --no-install-recommends g++ make gcc git build-essential ca-certificates \
&& update-ca-certificates 2>/dev/null || true \
&& rm -rf /var/lib/apt/lists/*
ENV GO111MODULE=on \
CGO_ENABLED=1 \
@ -25,17 +28,12 @@ ADD go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=builder /web/build ./web/build
RUN go build -trimpath -ldflags "-s -w -X 'github.com/songquanpeng/one-api/common.Version=$(cat VERSION)'" -o one-api
RUN go build -trimpath -ldflags "-s -w -X 'github.com/songquanpeng/one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
FROM debian:bullseye
RUN apt-get update
RUN apt-get install -y --no-install-recommends ca-certificates haveged tzdata \
# for google-chrome
# libappindicator1 fonts-liberation xdg-utils wget \
# libasound2 libatk-bridge2.0-0 libatspi2.0-0 libcurl3-gnutls libcurl3-nss \
# libcurl4 libcurl3 libdrm2 libgbm1 libgtk-3-0 libgtk-4-1 libnspr4 libnss3 \
# libu2f-udev libvulkan1 libxkbcommon0 \
&& update-ca-certificates 2>/dev/null || true \
&& rm -rf /var/lib/apt/lists/*