From bd722767ba695059e610d60597a1836708f0e300 Mon Sep 17 00:00:00 2001 From: Sun <95302870@qq.com> Date: Sun, 10 Dec 2023 17:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=90=8E=E7=AB=AFalpine?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E9=95=9C=E5=83=8F3.18=E6=97=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E6=96=B0=E7=89=88=E6=9C=AC=E5=AF=BC=E8=87=B4?= =?UTF-8?q?sqlite3=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 40e82be..5e63063 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ -# build front-end +# build frontend FROM node AS web_image +# 华为源 +# RUN npm config set registry https://repo.huaweicloud.com/repository/npm/ + RUN npm install pnpm -g WORKDIR /build @@ -16,17 +19,22 @@ COPY . /build RUN pnpm run build # build backend -FROM golang:1.21-alpine as server_image +# 最新alpine3.19导致sqlite3编译失败(https://github.com/mattn/go-sqlite3/issues/1164, +# 临时解决方案:https://github.com/mattn/go-sqlite3/pull/1177) +# sun-panel暂时解决方案使用golang:1.21-alpine3.18(因旧版本使用没问题,短期内较稳定) +FROM golang:1.21-alpine3.18 as server_image WORKDIR /build COPY ./service . -RUN apk add --no-cache bash curl gcc git go musl-dev +# 中国国内源 +# RUN sed -i "s@dl-cdn.alpinelinux.org@mirrors.aliyun.com@g" /etc/apk/repositories \ +# && go env -w GOPROXY=https://goproxy.cn,direct +RUN apk add --no-cache bash curl gcc git musl-dev RUN go env -w GO111MODULE=on \ - # && go env -w GOPROXY=https://goproxy.cn,direct \ && export PATH=$PATH:/go/bin \ && go install -a -v github.com/go-bindata/go-bindata/...@latest \ && go install -a -v github.com/elazarl/go-bindata-assetfs/...@latest \ @@ -34,6 +42,7 @@ RUN go env -w GO111MODULE=on \ && go build -o sun-panel --ldflags="-X sun-panel/global.RUNCODE=release -X sun-panel/global.ISDOCKER=docker" main.go + # run_image FROM alpine @@ -43,6 +52,9 @@ COPY --from=web_image /build/dist /app/web COPY --from=server_image /build/sun-panel /app/sun-panel +# 中国国内源 +# RUN sed -i "s@dl-cdn.alpinelinux.org@mirrors.aliyun.com@g" /etc/apk/repositories + RUN apk add --no-cache bash ca-certificates su-exec tzdata \ && chmod +x ./sun-panel \ && ./sun-panel -config