mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
Hopefully fixed ARMv7 Rootless build
This commit is contained in:
@@ -31,6 +31,8 @@ RUN go mod download
|
|||||||
|
|
||||||
# Build API stage
|
# Build API stage
|
||||||
FROM public.ecr.aws/docker/library/golang:alpine AS builder
|
FROM public.ecr.aws/docker/library/golang:alpine AS builder
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
ARG BUILD_TIME
|
ARG BUILD_TIME
|
||||||
ARG COMMIT
|
ARG COMMIT
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
@@ -38,7 +40,8 @@ ARG VERSION
|
|||||||
# Install necessary build tools
|
# Install necessary build tools
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk upgrade && \
|
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
|
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
|
# Use cache for Go build artifacts
|
||||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
if [ "$TARGETARCH" = "arm" ] || [ "$TARGETARCH" = "riscv64" ]; \
|
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" \
|
-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; \
|
-tags nodynamic -o /go/bin/api -v ./app/api/*.go; \
|
||||||
else \
|
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" \
|
-ldflags "-s -w -X main.commit=$COMMIT -X main.buildTime=$BUILD_TIME -X main.version=$VERSION" \
|
||||||
-o /go/bin/api -v ./app/api/*.go; \
|
-o /go/bin/api -v ./app/api/*.go; \
|
||||||
fi
|
fi
|
||||||
@@ -73,7 +76,7 @@ ENV HBOX_DATABASE_SQLITE_PATH=/data/homebox.db?_pragma=busy_timeout=2000&_pragma
|
|||||||
|
|
||||||
# Install necessary runtime dependencies
|
# Install necessary runtime dependencies
|
||||||
RUN apk --no-cache add ca-certificates wget && \
|
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
|
# Create a nonroot user with UID/GID 65532
|
||||||
RUN addgroup -g 65532 nonroot && adduser -u 65532 -G nonroot -S nonroot
|
RUN addgroup -g 65532 nonroot && adduser -u 65532 -G nonroot -S nonroot
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ services:
|
|||||||
image: homebox
|
image: homebox
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile.rootless
|
||||||
args:
|
args:
|
||||||
- COMMIT=head
|
- COMMIT=head
|
||||||
- BUILD_TIME=0001-01-01T00:00:00Z
|
- BUILD_TIME=0001-01-01T00:00:00Z
|
||||||
|
|||||||
Reference in New Issue
Block a user