mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2025-12-06 06:58:54 +08:00
ci:test arm64
This commit is contained in:
38
.github/workflows/goreleaser.yml
vendored
38
.github/workflows/goreleaser.yml
vendored
@@ -43,36 +43,30 @@ jobs:
|
||||
ls
|
||||
- name: Get current tag
|
||||
run: echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
- name: Login to Docker Hub
|
||||
# Login to Docker Hub
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_HUB_USER }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
# Set up Docker Buildx
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Build and Push Multi-Arch Docker Image
|
||||
run: |
|
||||
docker buildx create --use
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--push \
|
||||
--tag samwaf/samwaf:latest \
|
||||
--tag samwaf/samwaf:${{ env.IMAGE_TAG }} \
|
||||
--file Dockerfile \
|
||||
.
|
||||
|
||||
|
||||
docker buildx build \
|
||||
--platform linux/arm64 \
|
||||
--push \
|
||||
--tag samwaf/samwaf:latest \
|
||||
--tag samwaf/samwaf:${{ env.IMAGE_TAG }} \
|
||||
--file DockerfileArm \
|
||||
.
|
||||
uses: docker/setup-buildx-action@v2
|
||||
# Build and Push Docker Image for Multi-Arch
|
||||
- name: Build and Push Docker Image for Multi-Arch
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64 # Support for both architectures
|
||||
push: true # Push to Docker Hub
|
||||
tags: |
|
||||
samwaf/samwaf:latest
|
||||
samwaf/samwaf:${{ env.IMAGE_TAG }}
|
||||
# Test the Docker Image
|
||||
- name: Test Docker Image
|
||||
run: |
|
||||
# Print
|
||||
# Start the Docker container
|
||||
docker run -d --name=samwaf-instance \
|
||||
-p 26666:26666 \
|
||||
|
||||
20
Dockerfile
20
Dockerfile
@@ -12,11 +12,25 @@ RUN apk update && \
|
||||
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
||||
echo "${TZ}" > /etc/timezone
|
||||
|
||||
# 复制 release/SamWafLinux64 到镜像中 # 复制适用架构的二进制文件到镜像
|
||||
COPY dist/samwaf_linux_linux_amd64_v1/SamWafLinux64 ./SamWafLinux64
|
||||
# 定义构建参数(由 Buildx 提供)
|
||||
ARG TARGETARCH
|
||||
|
||||
# 根据架构动态复制对应的二进制文件
|
||||
# 只包含当前架构的文件
|
||||
ADD dist/samwaf_linux_linux_amd64_v1/SamWafLinux64 /app/SamWafLinux64.amd64
|
||||
ADD dist/samwaf_linux_arm64_linux_arm64/SamWafLinuxArm64 /app/SamWafLinux64.arm64
|
||||
|
||||
# 动态选择文件
|
||||
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
|
||||
mv /app/SamWafLinux64.amd64 /app/SamWafLinux64 && rm -f /app/SamWafLinux64.arm64; \
|
||||
elif [ "${TARGETARCH}" = "arm64" ]; then \
|
||||
mv /app/SamWafLinux64.arm64 /app/SamWafLinux64 && rm -f /app/SamWafLinux64.amd64; \
|
||||
else \
|
||||
echo "Unsupported architecture: ${TARGETARCH}" && exit 1; \
|
||||
fi
|
||||
|
||||
# 设置执行权限
|
||||
RUN chmod +x SamWafLinux64
|
||||
RUN chmod +x /app/SamWafLinux64
|
||||
|
||||
# 挂载 conf, data, logs 和 ssl 目录
|
||||
VOLUME ["/app/conf", "/app/data", "/app/logs", "/app/ssl"]
|
||||
|
||||
Reference in New Issue
Block a user