-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Dockerfile.build-and-run to realize multi-stage build;fix @testin… (
#813) * add Dockerfile.build-and-run to realize multi-stage build;fix @testing-library/user-event@7.2.1 has unmet peer dependency @testing-library/dom@>=5 * support download node.js according to linux arch * Revert "support download node.js according to linux arch" This reverts commit f39f4f7. * support download node.js according to linux arch * remove golang proxy of cn --------- Co-authored-by: zhongtong <zhongtong@isoftstone.com>
- Loading branch information
1 parent
488e130
commit ed37d45
Showing
2 changed files
with
70 additions
and
1 deletion.
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,69 @@ | ||
#docker build -t bililive-go:build . -f Dockerfile.build-and-run | ||
FROM golang:1.23.4-bullseye AS builder | ||
|
||
WORKDIR /build | ||
|
||
#安装tar解压xz需要的xz-utils和构建web页面所需的yarn | ||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ | ||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ | ||
apt-get update && \ | ||
apt-get install -y yarn xz-utils | ||
|
||
|
||
#根据架构安装构建web页面所需的node.js | ||
RUN ARCH=$(uname -m) && \ | ||
if [ $ARCH = 'x86_64' ]; then \ | ||
NODE_ARCH='x64'; \ | ||
elif [ $ARCH = 'aarch64' ]; then \ | ||
NODE_ARCH='arm64'; \ | ||
else \ | ||
echo '不支持的架构: $ARCH'; \ | ||
fi && \ | ||
wget https://nodejs.org/dist/v18.20.3/node-v18.20.3-linux-${NODE_ARCH}.tar.xz && \ | ||
tar Jxvf /build/node-v18.20.3-linux-${NODE_ARCH}.tar.xz && \ | ||
rm -rf /usr/bin/node /usr/bin/npm && \ | ||
ln -s /build/node-v18.20.3-linux-${NODE_ARCH}/bin/node /usr/bin/node && \ | ||
ln -s /build/node-v18.20.3-linux-${NODE_ARCH}/bin/npm /usr/bin/npm | ||
|
||
COPY . . | ||
|
||
#配置golang编译环境并进行构建 | ||
RUN go env -w GO111MODULE=on && \ | ||
make build-web && \ | ||
make | ||
|
||
RUN sh -c "/build/bin/bililive* --version" | ||
|
||
|
||
FROM alpine | ||
|
||
ARG tag | ||
|
||
ENV WORKDIR="/srv/bililive" | ||
ENV OUTPUT_DIR="/srv/bililive" \ | ||
CONF_DIR="/etc/bililive-go" \ | ||
PORT=8080 | ||
|
||
ENV PUID=0 PGID=0 UMASK=022 | ||
|
||
RUN mkdir -p $OUTPUT_DIR && \ | ||
mkdir -p $CONF_DIR && \ | ||
apk update && \ | ||
apk --no-cache add ffmpeg libc6-compat curl su-exec tzdata && \ | ||
cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | ||
|
||
COPY --from=builder /build/bin/bililive* /usr/bin/bililive-go | ||
|
||
|
||
COPY config.docker.yml $CONF_DIR/config.yml | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
|
||
VOLUME $OUTPUT_DIR | ||
|
||
EXPOSE $PORT | ||
|
||
WORKDIR ${WORKDIR} | ||
ENTRYPOINT [ "sh" ] | ||
CMD [ "/entrypoint.sh" ] |
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