Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bundling process #275

Merged
merged 6 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kubo/
go-ds-s3-plugin/go-ds-s3-plugin
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ As go plugins can be finicky to correctly compile and install, you may want to c
# We use go modules for everything.
> export GO111MODULE=on

# (Optionally) clean go cache
go clean -modcache
# Clone kubo.
> git clone https://github.com/ipfs/kubo
> cd kubo

# Pull in the datastore plugin (you can specify a version other than latest if you'd like).
> go get github.com/ipfs/go-ds-s3/plugin@latest
> go get github.com/ipfs/go-ds-s3@latest

# Add the plugin to the preload list.
> echo -en "\ns3ds github.com/ipfs/go-ds-s3/plugin 0" >> plugin/loader/preload_list
> echo -en "\ns3ds github.com/ipfs/go-ds-s3/go-ds-s3-plugin 0" >> plugin/loader/preload_list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about import path here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing "/go-ds-s3-plugin" doesn't work here. Build error: plugin/loader/preload.go:28:21: undefined: plugins3ds.Plugins
I assume GO needs the specific path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it to "github.com/ipfs/go-ds-s3/plugin" doesn't work as well.
-> I only manage to get it work with "github.com/ipfs/go-ds-s3/go-ds-s3-plugin".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR hasn't been merged nor released, so it can't be picked up automatically by go mod, did you tried adding a temporary replace github.com/ipfs/go-ds-s3 => ../go-ds-s3 to your Kubo go.mod file ? 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'm aware of that. I'm testing on a fork so I can mess around with master branch.
Temporary adding replace github.com/ipfs/go-ds-s3 => ../go-ds-s3 doesn't change the behavior described above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merge and this can be fixed in upcoming PR if still doesn't work.


# ( this first pass will fail ) Try to build kubo with the plugin
> make build
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.1-buster AS builder
FROM golang:1.21-bookworm AS builder

WORKDIR /

Expand All @@ -18,15 +18,15 @@ ENV SRC_DIR /kubo
WORKDIR $SRC_DIR

# Install the plugin and build ipfs
RUN go get github.com/ipfs/go-ds-s3/plugin@latest
RUN go get github.com/ipfs/go-ds-s3@latest
RUN echo "\ns3ds github.com/ipfs/go-ds-s3/plugin 0" >> plugin/loader/preload_list
RUN make build
RUN make build || : #first build will fail
RUN go mod tidy
RUN make build
RUN make install

# The actual IPFS image we will use
FROM ipfs/kubo:v0.19.2
FROM ipfs/kubo:v0.23.0
ENV SRC_DIR /kubo

# We copy the new binaries we built in the 'builder' stage (--from=builder)
Expand Down
2 changes: 1 addition & 1 deletion go-ds-s3-plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build: $(SRC)
go build -buildmode=plugin -trimpath -o go-ds-s3-plugin

install: build
mkdir -p "$(IPFS_PATH)/.ipfs/plugins"
mkdir -p "$(IPFS_PATH)/plugins"
install -Dm700 go-ds-s3-plugin "$(IPFS_PATH)/plugins/go-ds-s3-plugin"

dist: build
Expand Down
7 changes: 7 additions & 0 deletions go-ds-s3-plugin/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import (
plugin "github.com/ipfs/go-ds-s3/plugin"
)

var Plugins = plugin.Plugins //nolint
2 changes: 1 addition & 1 deletion go-ds-s3-plugin/s3ds.go → plugin/s3ds.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package plugin

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion go-ds-s3-plugin/s3ds_test.go → plugin/s3ds_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package plugin

import (
"reflect"
Expand Down