Skip to content

Commit e2cd060

Browse files
feat: add back arm64 support in Docker image (casdoor#2969)
1 parent 78c3065 commit e2cd060

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ jobs:
194194
with:
195195
context: .
196196
target: STANDARD
197-
platforms: linux/amd64
197+
platforms: linux/amd64,linux/arm64
198198
push: true
199199
tags: casbin/casdoor:${{steps.get-current-tag.outputs.tag }},casbin/casdoor:latest
200200

@@ -204,7 +204,7 @@ jobs:
204204
with:
205205
context: .
206206
target: ALLINONE
207-
platforms: linux/amd64
207+
platforms: linux/amd64,linux/arm64
208208
push: true
209209
tags: casbin/casdoor-all-in-one:${{steps.get-current-tag.outputs.tag }},casbin/casdoor-all-in-one:latest
210210

Dockerfile

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM node:18.19.0 AS FRONT
1+
FROM --platform=$BUILDPLATFORM node:18.19.0 AS FRONT
22
WORKDIR /web
33
COPY ./web .
44
RUN yarn install --frozen-lockfile --network-timeout 1000000 && yarn run build
55

66

7-
FROM golang:1.20.12 AS BACK
7+
FROM --platform=$BUILDPLATFORM golang:1.20.12 AS BACK
88
WORKDIR /go/src/casdoor
99
COPY . .
1010
RUN ./build.sh
@@ -13,6 +13,9 @@ RUN go test -v -run TestGetVersionInfo ./util/system_test.go ./util/system.go >
1313
FROM alpine:latest AS STANDARD
1414
LABEL MAINTAINER="https://casdoor.org/"
1515
ARG USER=casdoor
16+
ARG TARGETOS
17+
ARG TARGETARCH
18+
ENV BUILDX_ARCH="${TARGETOS:-linux}_${TARGETARCH:-amd64}"
1619

1720
RUN sed -i 's/https/http/' /etc/apk/repositories
1821
RUN apk add --update sudo
@@ -28,7 +31,7 @@ RUN adduser -D $USER -u 1000 \
2831

2932
USER 1000
3033
WORKDIR /
31-
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/server ./server
34+
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/server_${BUILDX_ARCH} ./server
3235
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/swagger ./swagger
3336
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/conf/app.conf ./conf/app.conf
3437
COPY --from=BACK --chown=$USER:$USER /go/src/casdoor/version_info.txt ./go/src/casdoor/version_info.txt
@@ -47,12 +50,15 @@ RUN apt update \
4750

4851
FROM db AS ALLINONE
4952
LABEL MAINTAINER="https://casdoor.org/"
53+
ARG TARGETOS
54+
ARG TARGETARCH
55+
ENV BUILDX_ARCH="${TARGETOS:-linux}_${TARGETARCH:-amd64}"
5056

5157
RUN apt update
5258
RUN apt install -y ca-certificates && update-ca-certificates
5359

5460
WORKDIR /
55-
COPY --from=BACK /go/src/casdoor/server ./server
61+
COPY --from=BACK /go/src/casdoor/server_${BUILDX_ARCH} ./server
5662
COPY --from=BACK /go/src/casdoor/swagger ./swagger
5763
COPY --from=BACK /go/src/casdoor/docker-entrypoint.sh /docker-entrypoint.sh
5864
COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf

build.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ else
88
echo "Google is blocked, Go proxy is enabled: GOPROXY=https://goproxy.cn,direct"
99
export GOPROXY="https://goproxy.cn,direct"
1010
fi
11-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o server .
11+
12+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o server_linux_amd64 .
13+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o server_linux_arm64 .

0 commit comments

Comments
 (0)