Skip to content

Commit

Permalink
add Dockerfile.build-and-run to realize multi-stage build;fix @testin… (
Browse files Browse the repository at this point in the history
#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
ColorfulDick and zhongtong authored Dec 14, 2024
1 parent 488e130 commit ed37d45
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
69 changes: 69 additions & 0 deletions Dockerfile.build-and-run
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" ]
2 changes: 1 addition & 1 deletion src/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": "./",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/jest-dom": "^5.0.0",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
Expand Down

0 comments on commit ed37d45

Please sign in to comment.