-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #355 from BennettChina/main
修复一些BUG以及增加Action构建基础镜像的功能
- Loading branch information
Showing
13 changed files
with
362 additions
and
187 deletions.
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
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,51 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'dev' | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./Dockerfile.base | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
USE_MIRROR=false | ||
platforms: linux/amd64,linux/arm64 |
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
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,83 @@ | ||
FROM alpine:3.20 AS resource | ||
|
||
ARG USE_MIRROR=true | ||
|
||
RUN set -eux; \ | ||
emoji_url="https://github.com/samuelngs/apple-emoji-linux/releases/latest/download/AppleColorEmoji.ttf"; \ | ||
if $USE_MIRROR; then \ | ||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories; \ | ||
emoji_url="https://mirror.ghproxy.com/${emoji_url}"; \ | ||
fi; \ | ||
apk add --no-cache --update ca-certificates; \ | ||
update-ca-certificates; \ | ||
emoji_dir="/usr/share/fonts/emoji"; \ | ||
mkdir -p "${emoji_dir}"; \ | ||
wget "${emoji_url}" -O "${emoji_dir}/AppleColorEmoji.ttf" | ||
|
||
FROM node:18-alpine3.20 | ||
|
||
ARG USE_MIRROR=true | ||
|
||
ENV TZ=Asia/Shanghai \ | ||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \ | ||
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \ | ||
GOSU_VERSION=1.17 \ | ||
CI=1 | ||
|
||
COPY --from=resource /usr/share/fonts/emoji/AppleColorEmoji.ttf /usr/share/fonts/emoji/AppleColorEmoji.ttf | ||
COPY public/fonts/wqy-microhei-regular.ttf /usr/share/fonts/win/wqy-microhei-regular.ttf | ||
|
||
# Installs base package. | ||
RUN set -eux; \ | ||
if $USE_MIRROR; then \ | ||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories; \ | ||
fi; \ | ||
apk add --no-cache --update \ | ||
chromium \ | ||
nss \ | ||
freetype \ | ||
harfbuzz \ | ||
ca-certificates \ | ||
git \ | ||
tzdata \ | ||
dos2unix \ | ||
dumb-init; \ | ||
cp /usr/share/zoneinfo/$TZ /etc/localtime; \ | ||
echo $TZ > /etc/timezone; \ | ||
npm config set registry https://registry.npmmirror.com; \ | ||
npm i pnpm -g; \ | ||
pnpm config set registry https://registry.npmmirror.com; \ | ||
pnpm config set store-dir ~/.pnpm-store; \ | ||
rm -rf /var/cache/apk/*; \ | ||
\ | ||
apk add --no-cache --update --virtual .gosu-deps \ | ||
ca-certificates \ | ||
dpkg \ | ||
gnupg \ | ||
; \ | ||
\ | ||
update-ca-certificates; \ | ||
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ | ||
gosu_exe="https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ | ||
gosu_asc="https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ | ||
if $USE_MIRROR; then \ | ||
gosu_exe="https://mirror.ghproxy.com/${gosu_exe}"; \ | ||
gosu_asc="https://mirror.ghproxy.com/${gosu_asc}"; \ | ||
fi; \ | ||
wget -O /usr/local/bin/gosu "${gosu_exe}"; \ | ||
wget -O /usr/local/bin/gosu.asc "${gosu_asc}"; \ | ||
\ | ||
# verify the signature | ||
export GNUPGHOME="$(mktemp -d)"; \ | ||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ | ||
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ | ||
command -v gpgconf && gpgconf --kill all || :; \ | ||
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \ | ||
\ | ||
# clean up fetch dependencies | ||
apk del --no-network .gosu-deps; \ | ||
\ | ||
chmod +x /usr/local/bin/gosu; \ | ||
# verify that the binary works | ||
gosu --version; \ | ||
gosu nobody true |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
#!/bin/sh | ||
set -e | ||
# 设置文件所属的用户和用户组(排除数据库使用的database目录) | ||
#find . -type d \( -path ./database -o -path ./qsign -o \) -prune -o -print | xargs chown adachi:adachi | ||
find . \! -user adachi -exec chown adachi '{}' + | ||
|
||
# 切换用户前执行依赖安装操作,处理 pnpm 创建文件夹权限不够的问题 | ||
pnpm i -P --no-frozen-lockfile | ||
|
||
find . \! -user adachi -exec test -e '{}' \; -exec chown adachi '{}' + | ||
|
||
# 使用 gosu 切换到 adachi 用户启动 dumb-init | ||
exec gosu adachi dumb-init -- "$@" |
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
Oops, something went wrong.