~Docker构建优化

This commit is contained in:
juewuy
2025-12-17 22:00:25 +08:00
parent c6a18a8981
commit aa324029cd
2 changed files with 9 additions and 19 deletions

View File

@@ -1,6 +1,8 @@
name: docker-build-push name: Build Docker image for ShellCrash
on: on:
push:
branches: [ master ]
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@@ -14,25 +16,24 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v5
with: with:
ref: dev
fetch-depth: 1 fetch-depth: 1
# QEMU 支持 - name: Read version
id: read_version
run: echo "VERSION=$(cat version)" >> $GITHUB_ENV
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
# buildx
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
# 登录 Docker Hub
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
# 构建并推送
- name: Build and push (multi-arch) - name: Build and push (multi-arch)
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
@@ -46,4 +47,4 @@ jobs:
push: true push: true
tags: | tags: |
${{ secrets.DOCKERHUB_USERNAME }}/shellcrash:latest ${{ secrets.DOCKERHUB_USERNAME }}/shellcrash:latest
${{ secrets.DOCKERHUB_USERNAME }}/shellcrash:${{ github.ref_name }} ${{ secrets.DOCKERHUB_USERNAME }}/shellcrash:${{ env.VERSION }}

View File

@@ -7,14 +7,7 @@ ARG TARGETPLATFORM
ARG TZ=Asia/Shanghai ARG TZ=Asia/Shanghai
ARG S6_OVERLAY_V=v3.2.1.0 ARG S6_OVERLAY_V=v3.2.1.0
RUN apk add --no-cache \ RUN apk add --no-cache curl tzdata
curl \
ca-certificates \
tar \
gzip \
xz \
tzdata \
dcron
# 时区 # 时区
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \ RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
@@ -60,16 +53,12 @@ ARG TZ=Asia/Shanghai
LABEL org.opencontainers.image.source="https://github.com/juewuy/ShellCrash" LABEL org.opencontainers.image.source="https://github.com/juewuy/ShellCrash"
#安装依赖 #安装依赖
RUN apk add --no-cache \ RUN apk add --no-cache \
tini \
openrc \
wget \ wget \
ca-certificates \ ca-certificates \
tzdata \ tzdata \
nftables \ nftables \
iproute2 \ iproute2 \
dcron dcron
#清理openrc
RUN apk del openrc && rm -rf /etc/runlevels/* /run/openrc
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \ RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo "${TZ}" > /etc/timezone echo "${TZ}" > /etc/timezone