Skip to content

Commit 4503f8e

Browse files
committed
ci: added docker image for easy build process
1 parent 30bd18c commit 4503f8e

File tree

9 files changed

+158
-12
lines changed

9 files changed

+158
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ipfs
2+
.vscode

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# FROM ubuntu:20.04
2+
FROM golang:1.18.1
3+
4+
LABEL maintainer "Perfection <[email protected]>"
5+
6+
# update apt and install dependencies
7+
# RUN export TZ="Asia/Jakarta" && \
8+
# export DEBIAN_FRONTEND=noninteractive && \
9+
# apt update && \
10+
# apt install -y golang-go git && \
11+
# echo "GIT VERSION IS -- $(git --version)"
12+
13+
# clone ipfs
14+
RUN git clone https://github.com/ipfs/go-ipfs && \
15+
cd go-ipfs && \
16+
#git checkout release-v0.15.0 && \
17+
go get github.com/samperfect/go-ds-s3/[email protected]
18+
19+
20+
# Add the plugin to the preload list.
21+
RUN cd go-ipfs && \
22+
echo "\ns3ds github.com/samperfect/go-ds-s3/plugin 0" >> plugin/loader/preload_list &&\
23+
cat plugin/loader/preload_list && \
24+
cat plugin/loader/preload.go && \
25+
make build && \
26+
go mod tidy && \
27+
make build && \
28+
make install && \
29+
cp cmd/ipfs/ipfs /usr/local/bin/ipfs
30+
31+
# checkpoint --- echo ipfs version
32+
RUN ipfs version
33+
RUN echo "IPFS VERSION IS -- $(ipfs version)"
34+
35+
ENV IPFS_PATH /data/ipfs
36+
37+
ENV API_PORT 5002
38+
ENV GATEWAY_PORT 8080
39+
ENV SWARM_PORT 4001
40+
41+
# defining args to be passed in at build time
42+
ARG AWS_SECRET_KEY
43+
ARG AWS_ACCESS_KEY
44+
ARG AWS_REGION
45+
ARG AWS_S3_BUCKET
46+
47+
ENV AWS_SECRET_KEY $AWS_SECRET_KEY
48+
ENV AWS_ACCESS_KEY $AWS_ACCESS_KEY
49+
ENV AWS_REGION $AWS_REGION
50+
ENV AWS_S3_BUCKET $AWS_S3_BUCKET
51+
52+
EXPOSE ${SWARM_PORT}
53+
# This may introduce security risk to expose API_PORT public
54+
# EXPOSE ${API_PORT}
55+
EXPOSE ${GATEWAY_PORT}
56+
57+
RUN mkdir -p ${IPFS_PATH}
58+
59+
# no need to for this as docker runs in root user mode
60+
# RUN chown ubuntu:ubuntu ${IPFS_PATH}
61+
62+
# configure ipfs for production
63+
RUN ipfs init -p server
64+
65+
RUN ipfs config Datastore.StorageMax 150GB && \
66+
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
67+
68+
RUN ipfs config --json Datastore.Spec "{\"mounts\":[{\"child\":{\"accessKey\":\"${AWS_ACCESS_KEY}\",\"bucket\":\"${AWS_S3_BUCKET}\",\"region\":\"${AWS_REGION}\",\"secretKey\":\"${AWS_SECRET_KEY}\",\"type\":\"s3ds\"},\"mountpoint\":\"/blocks\",\"prefix\":\"s3.datastore\",\"type\":\"measure\"},{\"child\": {\"compression\":\"none\",\"path\":\"datastore\",\"type\":\"levelds\"},\"mountpoint\": \"/\",\"prefix\":\"leveldb.datastore\",\"type\":\"measure\"}],\"type\":\"mount\"}"
69+
70+
RUN echo "{\"mounts\":[{\"bucket\":\"${AWS_S3_BUCKET}\",\"mountpoint\":\"/blocks\",\"region\":\"${AWS_REGION}\",\"rootDirectory\":\"\"},{\"mountpoint\":\"/\",\"path\":\"datastore\",\"type\":\"levelds\"}],\"type\":\"mount\"}" > $IPFS_PATH/datastore_spec
71+
72+
# by default, run `ipfs daemon` to start as a running node
73+
ENTRYPOINT ipfs daemon --enable-gc

Dockerfile.old

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
FROM ubuntu:18.04
2+
3+
LABEL maintainer "Perfection <[email protected]>"
4+
5+
# update apt and install dependencies
6+
RUN export TZ="Asia/Jakarta" && \
7+
export DEBIAN_FRONTEND=noninteractive && \
8+
apt update && \
9+
apt install -y golang-go git && \
10+
echo "GIT VERSION IS -- $(git --version)"
11+
12+
# clone ipfs
13+
# RUN git clone https://github.com/ipfs/go-ipfs && \
14+
# cd go-ipfs && \
15+
# git checkout release-v0.15.0 && \
16+
# go get github.com/samperfect/go-ds-s3/[email protected] && \
17+
# # Add the plugin to the preload list.
18+
# echo -en "\ns3ds github.com/samperfect/go-ds-s3/plugin 0" >> plugin/loader/preload_list && \
19+
# # make build && \
20+
# # go mod tidy && \
21+
# # make build && \
22+
# # make install && \
23+
24+
# install docker updates
25+
RUN apt-get update && apt-get upgrade -y && apt-get install libc6 && apt-get install --no-install-recommends --assume-yes \
26+
docker.io
27+
28+
RUN apt-get install -y libssl-dev \
29+
ca-certificates \
30+
fuse
31+
32+
33+
ENV IPFS_PATH /data/ipfs
34+
35+
ENV API_PORT 5002
36+
ENV GATEWAY_PORT 8080
37+
ENV SWARM_PORT 4001
38+
39+
# defining args to be passed in at build time
40+
ARG AWS_SECRET_KEY
41+
ARG AWS_ACCESS_KEY
42+
ARG AWS_REGION
43+
ARG AWS_S3_BUCKET
44+
45+
EXPOSE ${SWARM_PORT}
46+
# This may introduce security risk to expose API_PORT public
47+
# EXPOSE ${API_PORT}
48+
EXPOSE ${GATEWAY_PORT}
49+
50+
RUN mkdir -p ${IPFS_PATH}
51+
52+
COPY ipfs ipfs
53+
RUN mv ipfs /usr/local/bin/ipfs
54+
55+
# checkpoint --- echo ipfs version
56+
RUN ipfs version
57+
RUN echo "IPFS VERSION IS -- $(ipfs version)"
58+
59+
# no need to for this as docker runs in root user mode
60+
# RUN chown ubuntu:ubuntu ${IPFS_PATH}
61+
62+
# configure ipfs for production
63+
RUN ipfs init -p server
64+
65+
RUN ipfs config Datastore.StorageMax 150GB && \
66+
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
67+
68+
RUN ipfs config --json Datastore.Spec "{\"mounts\":[{\"child\":{\"accessKey\":\"${AWS_ACCESS_KEY}\",\"bucket\":\"${AWS_S3_BUCKET}\",\"region\":\"${AWS_REGION}\",\"secretKey\":\"${AWS_SECRET_KEY}\",\"type\":\"s3ds\"},\"mountpoint\":\"/blocks\",\"prefix\":\"s3.datastore\",\"type\":\"measure\"},{\"child\": {\"compression\":\"none\",\"path\":\"datastore\",\"type\":\"levelds\"},\"mountpoint\": \"/\",\"prefix\":\"leveldb.datastore\",\"type\":\"measure\"}],\"type\":\"mount\"}"
69+
RUN echo "{\"mounts\":[{\"bucket\":\"${AWS_S3_BUCKET}\",\"mountpoint\":\"/blocks\",\"region\":\"${AWS_REGION}\",\"rootDirectory\":\"\"},{\"mountpoint\":\"/\",\"path\":\"datastore\",\"type\":\"levelds\"}],\"type\":\"mount\"}" > $IPFS_PATH/datastore_spec
70+
71+
# by default, run `ipfs daemon` to start as a running node
72+
ENTRYPOINT ipfs daemon --enable-gc

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ This is an implementation of the datastore interface backed by amazon s3.
66

77
## Building and Installing
88

9-
You must build the plugin with the *exact* version of go used to build the go-ipfs binary you will use it with. You can find the go version for go-ipfs builds from dist.ipfs.io in the build-info file, e.g. https://dist.ipfs.io/go-ipfs/v0.4.22/build-info or by running `ipfs version --all`.
9+
You must build the plugin with the _exact_ version of go used to build the go-ipfs binary you will use it with. You can find the go version for go-ipfs builds from dist.ipfs.io in the build-info file, e.g. https://dist.ipfs.io/go-ipfs/v0.4.22/build-info or by running `ipfs version --all`.
1010

1111
In addition to needing the exact version of go, you need to build the correct version of this plugin.
1212

13-
* To build against a released version of go-ipfs, checkout the `release/v$VERSION` branch and build.
14-
* To build against a custom (local) build of go-ipfs, run `make IPFS_VERSION=/path/to/go-ipfs/source`.
13+
- To build against a released version of go-ipfs, checkout the `release/v$VERSION` branch and build.
14+
- To build against a custom (local) build of go-ipfs, run `make IPFS_VERSION=/path/to/go-ipfs/source`.
1515

1616
You can then install it into your local IPFS repo by running `make install`.
1717

@@ -53,11 +53,12 @@ For a brand new ipfs instance (no data stored yet):
5353
1. Copy s3plugin.so $IPFS_DIR/plugins/go-ds-s3.so (or run `make install` if you are installing locally).
5454
2. Run `ipfs init`.
5555
3. Edit $IPFS_DIR/config to include s3 details (see Configuration below).
56-
4. Overwrite `$IPFS_DIR/datastore_spec` as specified below (*Don't do this on an instance with existing data - it will be lost*).
56+
4. Overwrite `$IPFS_DIR/datastore_spec` as specified below (_Don't do this on an instance with existing data - it will be lost_).
5757

5858
### Configuration
5959

6060
The config file should include the following:
61+
6162
```json
6263
{
6364
"Datastore": {
@@ -116,7 +117,7 @@ Otherwise, you need to do a datastore migration.
116117

117118
## Contribute
118119

119-
Feel free to join in. All welcome. Open an [issue](https://github.com/lighthouse-web3/go-ds-s3/issues)!
120+
Feel free to join in. All welcome. Open an [issue](https://github.com/samperfect/go-ds-s3/issues)!
120121

121122
### Want to hack on IPFS?
122123

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/lighthouse-web3/go-ds-s3
1+
module github.com/samperfect/go-ds-s3
22

33
go 1.18
44

plugin/main/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
plugin "github.com/lighthouse-web3/go-ds-s3/plugin"
4+
plugin "github.com/samperfect/go-ds-s3/plugin"
55
)
66

77
var Plugins = plugin.Plugins //nolint

plugin/s3ds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/ipfs/kubo/plugin"
77
"github.com/ipfs/kubo/repo"
88
"github.com/ipfs/kubo/repo/fsrepo"
9-
s3ds "github.com/lighthouse-web3/go-ds-s3"
9+
s3ds "github.com/samperfect/go-ds-s3"
1010
)
1111

1212
var Plugins = []plugin.Plugin{

plugin/s3ds_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
"reflect"
55
"testing"
66

7-
s3ds "github.com/lighthouse-web3/go-ds-s3"
7+
s3ds "github.com/samperfect/go-ds-s3"
88
)
99

1010
func TestS3PluginDatastoreConfigParser(t *testing.T) {
11+
1112
testcases := []struct {
1213
Input map[string]interface{}
1314
Want *S3Config

0 commit comments

Comments
 (0)