Skip to content

Commit

Permalink
Merge pull request #258 from opencloud-eu/staticBinaryIssue
Browse files Browse the repository at this point in the history
static binary issue
  • Loading branch information
butonic authored Feb 27, 2025
2 parents 3632f76 + 71c03e8 commit 2c58ba2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 1 addition & 7 deletions .make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ DEBUG_LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPol
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseDataPathValue=/var/lib/opencloud"
DOCKER_LDFLAGS += -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathType=path" -X "$(OC_REPO)/pkg/config/defaults.BaseConfigPathValue=/etc/opencloud"

# We can't link statically when vips is enabled but we still
# prefer static linking where possible
ifndef ENABLE_VIPS
DOCKER_LDFLAGS += -extldflags "-static"
endif

GCFLAGS += all=-N -l

.PHONY: all
Expand Down Expand Up @@ -107,7 +101,7 @@ build: $(BIN)/$(EXECUTABLE)
build-debug: $(BIN)/$(EXECUTABLE)-debug

$(BIN)/$(EXECUTABLE): $(SOURCES)
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS) $(DOCKER_LDFLAGS)' -o $@ ./cmd/$(NAME)
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME)

$(BIN)/$(EXECUTABLE)-debug: $(SOURCES)
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(DEBUG_LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME)
Expand Down
6 changes: 4 additions & 2 deletions opencloud/docker/Dockerfile.linux.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ RUN apk add bash make git curl gcc musl-dev libc-dev binutils-gold inotify-tools
COPY ./ /opencloud/

WORKDIR /opencloud/opencloud
RUN GOOS="${TARGETOS:-linux}" GOARCH="${TARGETARCH:-amd64}" make ci-go-generate build ENABLE_VIPS=true
RUN GOOS="${TARGETOS:-linux}" GOARCH="${TARGETARCH:-amd64}" make ci-go-generate release-linux-docker-${TARGETARCH} ENABLE_VIPS=true

FROM alpine:3.20
ARG VERSION
ARG REVISION
ARG TARGETOS
ARG TARGETARCH

RUN apk add --no-cache attr bash ca-certificates curl inotify-tools libc6-compat mailcap tree vips patch && \
echo 'hosts: files dns' >| /etc/nsswitch.conf
Expand Down Expand Up @@ -48,4 +50,4 @@ EXPOSE 9200/tcp
ENTRYPOINT ["/usr/bin/opencloud"]
CMD ["server"]

COPY --from=build /opencloud/opencloud/bin/opencloud /usr/bin/opencloud
COPY --from=build /opencloud/opencloud/dist/binaries/opencloud-linux-${TARGETARCH} /usr/bin/opencloud

0 comments on commit 2c58ba2

Please sign in to comment.