Skip to content

Commit ca84626

Browse files
committed
feat(docker) : can build image for amd64 and arm64
1 parent b7c6412 commit ca84626

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
# Stage 1: Build the application
2-
FROM golang:1.23-alpine AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder
33

44
ARG VERSION
55
ARG URL=https://github.com/LordPax/go-scan2epub
6+
ARG TARGETOS
7+
ARG TARGETARCH
68

79
WORKDIR /app
810

11+
RUN mkdir /books
912
RUN apk add --no-cache git && \
1013
git clone --branch ${VERSION} ${URL} . && \
1114
go mod download && \
12-
go build -o scan2epub
15+
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o scan2epub
1316

1417
# Stage 2: Create the final lightweight image
1518
FROM alpine:latest
1619

17-
RUN apk add --no-cache ca-certificates
18-
1920
WORKDIR /
2021

2122
COPY --from=builder /app/scan2epub /scan2epub
22-
23-
RUN mkdir books
24-
23+
COPY --from=builder /books /books
2524
VOLUME ["/root/.config/scan2epub", "/books"]
2625

2726
CMD ["/scan2epub", "inter"]

docker-build.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/bash
22

33
[ -z "$1" ] && echo "Usage: $0 <version>" && exit 1
4+
45
echo "Building version $1"
5-
docker build --build-arg VERSION=$1 -t lordpax/scan2epub:$1 -t lordpax/scan2epub:latest .
6-
docker push lordpax/scan2epub:$1
7-
docker push lordpax/scan2epub:latest
6+
7+
docker build \
8+
--platform linux/arm64,linux/amd64 \
9+
--build-arg VERSION=$1 \
10+
-t lordpax/scan2epub:$1 \
11+
-t lordpax/scan2epub:latest \
12+
--push .
13+
14+
[ $? -eq 0 ] && echo "Build successful" || echo "Build failed"

0 commit comments

Comments
 (0)