diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 8cf9589a..06a5737d 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -31,6 +31,8 @@ RUN go mod download # Build API stage FROM public.ecr.aws/docker/library/golang:alpine AS builder +ARG TARGETOS +ARG TARGETARCH ARG BUILD_TIME ARG COMMIT ARG VERSION @@ -38,7 +40,8 @@ ARG VERSION # Install necessary build tools RUN apk update && \ apk upgrade && \ - apk add --no-cache git build-base gcc g++ + apk add --no-cache git build-base gcc g++ && \ + if [ "$TARGETARCH" != "arm" ] || [ "$TARGETARCH" != "riscv64" ]; then apk --no-cache add libwebp libavif libheif libjxl; fi WORKDIR /go/src/app @@ -53,11 +56,11 @@ COPY --from=frontend-builder /app/.output/public ./app/api/static/public # Use cache for Go build artifacts RUN --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm" ] || [ "$TARGETARCH" = "riscv64" ]; \ - then CGO_ENABLED=0 GOOS=linux go build \ + then echo "nodynamic" $TARGETOS $TARGETARCH; CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \ -ldflags "-s -w -X main.commit=$COMMIT -X main.buildTime=$BUILD_TIME -X main.version=$VERSION" \ -tags nodynamic -o /go/bin/api -v ./app/api/*.go; \ else \ - CGO_ENABLED=0 GOOS=linux go build \ + echo $TARGETOS $TARGETARCH; CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \ -ldflags "-s -w -X main.commit=$COMMIT -X main.buildTime=$BUILD_TIME -X main.version=$VERSION" \ -o /go/bin/api -v ./app/api/*.go; \ fi @@ -73,7 +76,7 @@ ENV HBOX_DATABASE_SQLITE_PATH=/data/homebox.db?_pragma=busy_timeout=2000&_pragma # Install necessary runtime dependencies RUN apk --no-cache add ca-certificates wget && \ - if [ "$TARGETARCH" != "arm" ] || [ "$TARGETARCH" != "riscv64" ]; then apk --no-cache add libwebp libavif; fi + if [ "$TARGETARCH" != "arm" ] || [ "$TARGETARCH" != "riscv64" ]; then apk --no-cache add libwebp libavif libheif libjxl; fi # Create a nonroot user with UID/GID 65532 RUN addgroup -g 65532 nonroot && adduser -u 65532 -G nonroot -S nonroot diff --git a/docker-compose.yml b/docker-compose.yml index 1c41cef1..f576b709 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: image: homebox build: context: . - dockerfile: ./Dockerfile + dockerfile: ./Dockerfile.rootless args: - COMMIT=head - BUILD_TIME=0001-01-01T00:00:00Z