首次提交
All checks were successful
Build and Push TFTP Docker Image / docker-build-push (push) Successful in 29s
All checks were successful
Build and Push TFTP Docker Image / docker-build-push (push) Successful in 29s
This commit is contained in:
82
.gitea/workflows/ci.yaml
Normal file
82
.gitea/workflows/ci.yaml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
# .gitea/workflows/ci.yaml
|
||||||
|
name: Build and Push TFTP Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main, develop]
|
||||||
|
tags: ['*']
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOCKER_BUILDKIT: "1"
|
||||||
|
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker-build-push:
|
||||||
|
runs-on: ubuntu-latest-amd64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Debug branch info
|
||||||
|
run: |
|
||||||
|
echo "📋 Branch Information:"
|
||||||
|
echo " github.ref: ${{ github.ref }}"
|
||||||
|
echo " github.ref_name: ${{ github.ref_name }}"
|
||||||
|
echo " github.event_name: ${{ github.event_name }}"
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx and Login
|
||||||
|
run: |
|
||||||
|
# 设置 QEMU 支持多架构
|
||||||
|
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes 2>/dev/null || true
|
||||||
|
|
||||||
|
# 创建 buildx builder
|
||||||
|
docker buildx create --use --name tftpd_builder \
|
||||||
|
--driver docker-container \
|
||||||
|
--driver-opt network=host \
|
||||||
|
--driver-opt image=moby/buildkit:buildx-stable-1 \
|
||||||
|
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=50000000 \
|
||||||
|
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000 \
|
||||||
|
|| docker buildx use tftpd_builder
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
|
||||||
|
# 登录 Docker Registry
|
||||||
|
echo "${{ secrets.BUILD_TOKEN }}" | docker login ${{ gitea.server_url }} -u ${{ gitea.actor }} --password-stdin
|
||||||
|
|
||||||
|
- name: Determine Docker tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.ref_name }}" = "main" ]; then
|
||||||
|
TAG="latest"
|
||||||
|
elif [ "${{ github.ref_name }}" = "develop" ]; then
|
||||||
|
TAG="develop"
|
||||||
|
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||||
|
TAG="${{ github.ref_name }}"
|
||||||
|
else
|
||||||
|
TAG="${{ github.ref_name }}"
|
||||||
|
fi
|
||||||
|
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||||
|
echo "📦 Docker tag: ${TAG}"
|
||||||
|
|
||||||
|
- name: Build and push multi-arch Docker image
|
||||||
|
run: |
|
||||||
|
# 移除 URL 中的 https:// 前缀
|
||||||
|
REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
||||||
|
IMAGE_NAME="${REGISTRY}/${{ gitea.repository }}"
|
||||||
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
FINAL_IMAGE_TAG="${IMAGE_NAME}:${TAG}"
|
||||||
|
|
||||||
|
echo "🏗️ Building and pushing image: ${FINAL_IMAGE_TAG}"
|
||||||
|
echo " Platforms: linux/amd64, linux/arm64"
|
||||||
|
|
||||||
|
# 设置 BuildKit 优化参数
|
||||||
|
export BUILDKIT_PROGRESS=plain
|
||||||
|
|
||||||
|
docker buildx build --pull --push \
|
||||||
|
-t "${FINAL_IMAGE_TAG}" \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
--provenance=false \
|
||||||
|
--sbom=false \
|
||||||
|
-f Dockerfile .
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✅ Build and push completed!"
|
||||||
|
echo "🐳 Image: ${FINAL_IMAGE_TAG}"
|
||||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --no-cache tftp-hpa curl
|
||||||
|
|
||||||
|
RUN mkdir -p /var/lib/tftpboot
|
||||||
|
|
||||||
|
VOLUME /var/lib/tftpboot
|
||||||
|
|
||||||
|
EXPOSE 69/udp
|
||||||
|
|
||||||
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
WORKDIR /var/lib/tftpboot
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
25
entrypoint.sh
Normal file
25
entrypoint.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
TFTPBOOT_DIR="/var/lib/tftpboot"
|
||||||
|
|
||||||
|
if [ "$DOWNLOAD_NETBOOT_XYZ" = "true" ]; then
|
||||||
|
echo "DOWNLOAD_NETBOOT_XYZ is true. Downloading netboot.xyz files..."
|
||||||
|
|
||||||
|
mkdir -p "$TFTPBOOT_DIR"
|
||||||
|
|
||||||
|
curl -o "$TFTPBOOT_DIR/netboot.xyz-arm64.efi" https://boot.netboot.xyz/ipxe/netboot.xyz-arm64.efi
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error downloading netboot.xyz-arm64.efi"
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -o "$TFTPBOOT_DIR/netboot.xyz.efi" https://boot.netboot.xyz/ipxe/netboot.xyz.efi
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error downloading netboot.xyz.efi"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Download complete."
|
||||||
|
else
|
||||||
|
echo "DOWNLOAD_NETBOOT_XYZ is not true or not set. Skipping netboot.xyz file download."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec /usr/sbin/in.tftpd -L -vvv -u ftp --secure --address "0.0.0.0:69" "$TFTPBOOT_DIR"
|
||||||
Reference in New Issue
Block a user