Skip to content

Commit

Permalink
add platforms: linux/amd64,linux/arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
sjqzhang committed Sep 26, 2024
1 parent 7956318 commit eb5c732
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all # 启用所有支持的平台的模拟
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --allow-insecure-entitlement security.insecure
builder: default
use: true
- name: Log in to GitHub Container Registry
# 使用GITHUB_TOKEN登录,它允许操作推送容器镜像
uses: docker/login-action@v2
Expand All @@ -25,6 +35,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
file: ./DockerfileForGitAction
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest
push: true
38 changes: 38 additions & 0 deletions DockerfileForGitAction
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM --platform=$BUILDPLATFORM golang:1.18 AS builder
MAINTAINER s_jqzhang <[email protected]>
ARG VERSION=1.1.7
RUN set -xe; \
apk update; \
apk add --no-cache --virtual .build-deps \
git; \
mkdir -p /root/repo ; cd /root/repo ; \
git clone https://github.com/sjqzhang/go-fastdfs ; \
cd go-fastdfs; mv vendor src ; mv src .. ; cd .. ; mv go-fastdfs src/github.com/sjqzhang/ ; export GOPATH=/root/repo ; cd src/github.com/sjqzhang/go-fastdfs ; \
export GO111MODULE="off"; \
CGO_ENABLED=0 GOOS=linux go build GOARCH=$TARGETARCH -a -installsuffix cgo -o fileserver; \
ls -lh .;
FROM registry.cn-hangzhou.aliyuncs.com/prince/alpine-bash

COPY --from=builder /root/repo/src/github.com/sjqzhang/go-fastdfs/fileserver /

ENV INSTALL_DIR /usr/local/go-fastdfs

ENV PATH $PATH:$INSTALL_DIR/

ENV GO_FASTDFS_DIR $INSTALL_DIR/data

RUN set -xe; \
mkdir -p $GO_FASTDFS_DIR; \
mkdir -p $GO_FASTDFS_DIR/conf; \
mkdir -p $GO_FASTDFS_DIR/data; \
mkdir -p $GO_FASTDFS_DIR/files; \
mkdir -p $GO_FASTDFS_DIR/log; \
mkdir -p $INSTALL_DIR; \
mv /fileserver $INSTALL_DIR/; \
chmod +x $INSTALL_DIR/fileserver;

WORKDIR $INSTALL_DIR

VOLUME $GO_FASTDFS_DIR

CMD ["fileserver", "server" , "${OPTS}"]

0 comments on commit eb5c732

Please sign in to comment.