Skip to content

Commit

Permalink
build(docker): 添加beta打包配置
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuyelin committed Jan 8, 2024
1 parent 553a036 commit 46ecbe2
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 10 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ on:
- .github/workflows/build-beta.yml
- package_list.txt
- requirements.txt
- docker/Dockerfile
- docker/beta.Dockerfile

jobs:
alpine:
runs-on: ubuntu-latest
name: Build Docker Image (Alpine)
name: Build Docker Beta Image (Alpine)
steps:
-
name: Checkout
Expand All @@ -33,7 +33,7 @@ jobs:
id: release_version
run: |
app_version=$(cat version.py |sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
echo "app_version=${app_version}" >> $GITHUB_ENV
echo "app_version=${app_version}-beta" >> $GITHUB_ENV
- name: Docker metadata
id: meta
Expand All @@ -43,7 +43,7 @@ jobs:
${{ github.event.inputs.docker_username }}/nas-tools
tags: |
type=raw,value=${{ env.app_version }}
type=raw,value=latest
type=raw,value=beta
-
name: Set Up QEMU
Expand All @@ -65,7 +65,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: docker
file: docker/Dockerfile
file: docker/beta.Dockerfile
platforms: |
linux/amd64
linux/arm64
Expand All @@ -75,7 +75,7 @@ jobs:

debian:
runs-on: ubuntu-latest
name: Build Docker Image (Debian)
name: Build Docker Beta Image (Debian)
steps:
-
name: Checkout
Expand All @@ -86,7 +86,7 @@ jobs:
id: release_version
run: |
app_version=$(cat version.py |sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
echo "app_version=${app_version}-debian" >> $GITHUB_ENV
echo "app_version=${app_version}-debian-beta" >> $GITHUB_ENV
- name: Docker metadata
id: meta
Expand All @@ -96,7 +96,7 @@ jobs:
${{ github.event.inputs.docker_username }}/nas-tools
tags: |
type=raw,value=${{ env.app_version }}
type=raw,value=debian
type=raw,value=debian-beta
-
name: Set Up QEMU
Expand All @@ -118,7 +118,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: docker
file: docker/debian.Dockerfile
file: docker/debian-beta.Dockerfile
platforms: |
linux/amd64
linux/arm64
Expand Down
56 changes: 56 additions & 0 deletions docker/beta.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM python:3.10.11-alpine
RUN apk add --no-cache --virtual .build-deps \
libffi-dev \
gcc \
musl-dev \
libxml2-dev \
libxslt-dev \
&& apk add --no-cache $(echo $(wget --no-check-certificate -qO- https://raw.githubusercontent.com/hsuyelin/nas-tools/beta/package_list.txt)) \
&& curl https://rclone.org/install.sh | bash \
&& if [ "$(uname -m)" = "x86_64" ]; then ARCH=amd64; elif [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi \
&& curl https://dl.min.io/client/mc/release/linux-${ARCH}/mc --create-dirs -o /usr/bin/mc \
&& chmod +x /usr/bin/mc \
&& pip install --upgrade pip setuptools wheel \
&& pip install cython \
&& pip install -r https://raw.githubusercontent.com/hsuyelin/nas-tools/beta/requirements.txt \
&& apk del --purge .build-deps \
&& rm -rf /tmp/* /root/.cache /var/cache/apk/*
ENV S6_SERVICES_GRACETIME=30000 \
S6_KILL_GRACETIME=60000 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SYNC_DISKS=1 \
HOME="/nt" \
TERM="xterm" \
PATH=${PATH}:/usr/lib/chromium \
LANG="C.UTF-8" \
TZ="Asia/Shanghai" \
NASTOOL_CONFIG="/config/config.yaml" \
NASTOOL_AUTO_UPDATE=false \
NASTOOL_CN_UPDATE=true \
NASTOOL_VERSION=beta \
PS1="\u@\h:\w \$ " \
REPO_URL="https://github.com/hsuyelin/nas-tools.git" \
PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
ALPINE_MIRROR="mirrors.ustc.edu.cn" \
PUID=0 \
PGID=0 \
UMASK=000 \
WORKDIR="/nas-tools"
WORKDIR ${WORKDIR}
RUN mkdir ${HOME} \
&& addgroup -S nt -g 911 \
&& adduser -S nt -G nt -h ${HOME} -s /bin/bash -u 911 \
&& python_ver=$(python3 -V | awk '{print $2}') \
&& python_path=$(which python3) \
&& [ -d "/usr/lib/python${python_ver%.*}/site-packages" ] || mkdir -p "/usr/lib/python${python_ver%.*}/site-packages" \
&& echo "${WORKDIR}/" > /usr/lib/python${python_ver%.*}/site-packages/nas-tools.pth \
&& echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
&& echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
&& echo "nt ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& git config --global pull.ff only \
&& git clone -b beta ${REPO_URL} ${WORKDIR} --depth=1 --recurse-submodule \
&& git config --global --add safe.directory ${WORKDIR}
COPY --chmod=755 ./rootfs /
EXPOSE 3000
VOLUME ["/config"]
ENTRYPOINT [ "/init" ]
76 changes: 76 additions & 0 deletions docker/debian-beta.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
FROM python:3.10.11-slim-bullseye
COPY --from=shinsenter/s6-overlay / /
RUN set -xe && \
export DEBIAN_FRONTEND="noninteractive" && \
apt-get update -y && \
apt-get install -y wget bash && \
apt-get install -y $(echo $(wget --no-check-certificate -qO- https://raw.githubusercontent.com/hsuyelin/nas-tools/beta/package_list_debian.txt)) && \
ln -sf /command/with-contenv /usr/bin/with-contenv && \
# zone time
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo "${TZ}" > /etc/timezone && \
# locale
locale-gen zh_CN.UTF-8 && \
# chromedriver
ln -sf /usr/bin/chromedriver /usr/lib/chromium/chromedriver && \
# Python settings
update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 3 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2 && \
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 3 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2 && \
# Rclone
curl https://rclone.org/install.sh | bash && \
# Minio
if [ "$(uname -m)" = "x86_64" ]; then ARCH=amd64; elif [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi && \
curl https://dl.min.io/client/mc/release/linux-${ARCH}/mc --create-dirs -o /usr/bin/mc && \
chmod +x /usr/bin/mc && \
# Pip requirements prepare
apt-get install -y build-essential && \
# Pip requirements
pip install --upgrade pip setuptools wheel && \
pip install cython && \
pip install -r https://raw.githubusercontent.com/hsuyelin/nas-tools/beta/requirements.txt && \
# Clear
apt-get remove -y build-essential && \
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf \
/tmp/* \
/root/.cache \
/var/lib/apt/lists/* \
/var/tmp/*
ENV S6_SERVICES_GRACETIME=30000 \
S6_KILL_GRACETIME=60000 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SYNC_DISKS=1 \
HOME="/nt" \
TERM="xterm" \
PATH=${PATH}:/usr/lib/chromium:/command \
TZ="Asia/Shanghai" \
NASTOOL_CONFIG="/config/config.yaml" \
NASTOOL_AUTO_UPDATE=false \
NASTOOL_CN_UPDATE=true \
NASTOOL_VERSION=beta \
REPO_URL="https://github.com/hsuyelin/nas-tools.git" \
PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
PUID=0 \
PGID=0 \
UMASK=000 \
WORKDIR="/nas-tools"
WORKDIR ${WORKDIR}
RUN set -xe \
&& mkdir ${HOME} \
&& groupadd -r nt -g 911 \
&& useradd -r nt -g nt -d ${HOME} -s /bin/bash -u 911 \
&& python_ver=$(python3 -V | awk '{print $2}') \
&& echo "${WORKDIR}/" > /usr/local/lib/python${python_ver%.*}/site-packages/nas-tools.pth \
&& echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
&& echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
&& echo "nt ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& git config --global pull.ff only \
&& git clone -b beta ${REPO_URL} ${WORKDIR} --depth=1 --recurse-submodule \
&& git config --global --add safe.directory ${WORKDIR}
COPY --chmod=755 ./rootfs /
EXPOSE 3000
VOLUME [ "/config" ]
ENTRYPOINT [ "/init" ]
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
APP_VERSION = 'v3.4.0-beta'
APP_VERSION = 'v3.4.0'

0 comments on commit 46ecbe2

Please sign in to comment.