mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2025-12-06 14:59:18 +08:00
ci:test arm64
This commit is contained in:
37
.github/workflows/goreleaser.yml
vendored
37
.github/workflows/goreleaser.yml
vendored
@@ -43,26 +43,33 @@ jobs:
|
||||
ls
|
||||
- name: Get current tag
|
||||
run: echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
# Login to Docker Hub
|
||||
- name: Login to Docker Registry
|
||||
- name: Login to Docker Hub
|
||||
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@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 }}
|
||||
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 \
|
||||
.
|
||||
# Test the Docker Image
|
||||
- name: Test Docker Image
|
||||
run: |
|
||||
|
||||
13
Dockerfile
13
Dockerfile
@@ -12,17 +12,8 @@ RUN apk update && \
|
||||
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
||||
echo "${TZ}" > /etc/timezone
|
||||
|
||||
# 复制适用架构的二进制文件到镜像
|
||||
ARG TARGETARCH
|
||||
RUN echo "Building for architecture: ${TARGETARCH}"
|
||||
# 使用RUN指令和if语句根据架构选择文件
|
||||
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
|
||||
cp dist/samwaf_linux_linux_amd64_v1/SamWafLinux64 ./SamWafLinux64; \
|
||||
elif [ "${TARGETARCH}" = "arm64" ]; then \
|
||||
cp dist/samwaf_linux_arm64_linux_arm64/SamWafLinuxArm64 ./SamWafLinux64; \
|
||||
else \
|
||||
echo "Unknown architecture: ${TARGETARCH}" && exit 1; \
|
||||
fi
|
||||
# 复制 release/SamWafLinux64 到镜像中 # 复制适用架构的二进制文件到镜像
|
||||
COPY dist/samwaf_linux_linux_amd64_v1/SamWafLinux64 ./SamWafLinux64
|
||||
|
||||
# 设置执行权限
|
||||
RUN chmod +x SamWafLinux64
|
||||
|
||||
27
DockerfileArm
Normal file
27
DockerfileArm
Normal file
@@ -0,0 +1,27 @@
|
||||
FROM alpine:latest
|
||||
LABEL authors="samwaf"
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 设置默认时区为上海
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
# 更新并安装时区数据
|
||||
RUN apk update && \
|
||||
apk add --no-cache tzdata && \
|
||||
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
||||
echo "${TZ}" > /etc/timezone
|
||||
|
||||
# 复制 release/SamWafLinux64 到镜像中
|
||||
COPY dist/samwaf_linux_arm64_linux_arm64/SamWafLinuxArm64 ./SamWafLinux64
|
||||
# 设置执行权限
|
||||
RUN chmod +x SamWafLinux64
|
||||
|
||||
# 挂载 conf, data, logs 和 ssl 目录
|
||||
VOLUME ["/app/conf", "/app/data", "/app/logs", "/app/ssl"]
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 26666 80 443
|
||||
|
||||
# 设置默认命令来启动 SamWafLinux64
|
||||
CMD ["./SamWafLinux64"]
|
||||
Reference in New Issue
Block a user