Skip to content

Commit

Permalink
Merge pull request #62 from covalenthq/develop
Browse files Browse the repository at this point in the history
IPFS-Pinner-DTM-RC:v0.1.13
  • Loading branch information
noslav authored May 10, 2023
2 parents c583fbd + 03969fc commit fc8bd05
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ COPY --from=builder /build/ipfs-server /app
SHELL ["/bin/bash", "-c"]
RUN chmod +x ./ipfs-server

HEALTHCHECK --interval=10s --timeout=5s CMD wget --no-verbose --tries=1 --spider localhost:3000/health
HEALTHCHECK --interval=10s --timeout=5s CMD wget --no-verbose --tries=1 --spider localhost:3001/health

ENTRYPOINT [ "/bin/bash", "-l", "-c" ]
CMD [ "./ipfs-server -port 3000 -jwt $WEB3_JWT" ]
CMD [ "./ipfs-server -port 3001 -jwt $WEB3_JWT" ]

# ipfs-pinner API server;
EXPOSE 3000
EXPOSE 3001
# Swarm TCP; should be exposed to the public
EXPOSE 4001
# Daemon API; must not be exposed publicly but to client services under you control
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To avoid this issue, the merkle DAG thus generated is exported into special file

1. Set the environment variable `WEB3_JWT`

2. to start a server which listens for request on 3000 port, run:
2. to start a server which listens for request on 3001 port, run:

```bash
make clean server-dbg run
Expand All @@ -47,7 +47,7 @@ make clean server-dbg run
NOTE: If you want more control over CLI params, you can run the server binary (after `make clean server-dbg`):

```bash
./build/bin/server -jwt <WEB3_JWT> -port 3000
./build/bin/server -jwt <WEB3_JWT> -port 3001
```

NOTE: If you get some error when running this, check if the diagnostic is there in [known issues](#known-issues)
Expand All @@ -59,14 +59,14 @@ ipfs-pinner can be run as a server and allows two functionalities currently - `/
- Submit a request to upload a file (using multipart/form-data):

```bash
➜ curl -F "filedata=@file_to_upload" http://127.0.0.1:3000/upload
➜ curl -F "filedata=@file_to_upload" http://127.0.0.1:3001/upload
{"cid": "QmUqcL1RwbnbQ3FzmnT1aeRk8g8L5naKinJd5hCuPXxbZ2"}
```

Failures will be reported (via "error" field in the json). E.g:

```bash
➜ curl -F "filedata=@non_existent_file" http://127.0.0.1:3000/upload
➜ curl -F "filedata=@non_existent_file" http://127.0.0.1:3001/upload
{"error": "open not_exist_file: no such file or directory"}
```

Expand All @@ -83,7 +83,7 @@ There's a timeout (check code for value), on timeout the error message returned
If the request succeeds the raw content is sent back and it can be outputted in a file using curl. e.g.

```bash
➜ curl -XGET http://127.0.0.1:3000/get\?cid\=bafybeifzst7cbujrqemiulznrkttouzshnqkrajiib5fp5te53ojs5sl5u --output file.jpeg
➜ curl -XGET http://127.0.0.1:3001/get\?cid\=bafybeifzst7cbujrqemiulznrkttouzshnqkrajiib5fp5te53ojs5sl5u --output file.jpeg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 806k 0 806k 0 0 91.2M 0 --:--:-- --:--:-- --:--:-- 262M
Expand All @@ -99,7 +99,7 @@ There's a timeout (check code for value) for the download request, if it doesn't
### Find the cid given some content

```bash
➜ curl -F "filedata=@LICENSE" http://127.0.0.1:3000/cid
➜ curl -F "filedata=@LICENSE" http://127.0.0.1:3001/cid
{"cid": "bafkreicszve3ewhhrgobm366mdctki2m2qwzide5e54zh5aifnesg3ofne"}%
```

Expand All @@ -126,7 +126,7 @@ Now, we can run the container:
```bash
docker container run --detach --name ipfs-pinner-instance \
--volume /tmp/data/.ipfs/:/root/.ipfs/ \
-p 4001:4001 -p 3000:3000 \
-p 4001:4001 -p 3001:3001 \
--env WEB3_JWT=$WEB3_JWT \
<image-id>
```
Expand All @@ -140,9 +140,9 @@ There's 1 docker volume that needs to be shared (and persisted) between the cont
:4001 : swarm port for p2p
:8080 - http gateway (used by encapsulated ipfs-node)
:5001: local api (should be bound to 127.0.0.1 only, and must never be exposed publicly as it allows one to control the ipfs node; also used by encapsulated ipfs-node)
:3000: The ipfs-pinner itself exposes its REST API on this port
:3001: The ipfs-pinner itself exposes its REST API on this port

<B> Out of the above, only the swarm port and the REST api port (3000) are essential.</B>
<B> Out of the above, only the swarm port and the REST api port (3001) are essential.</B>

---

Expand Down Expand Up @@ -215,7 +215,7 @@ This effectively disables local host discovery and is recommended when running I
ipfs-pinner currently uses some known IPFS gateways to fetch content. These gateways are expected to be run and maintained for a long time, but if you need to update the gateways list due to one of the going down, or a more efficient gateway being introduced etc. you can change the list:
```bash
./build/bin/server -jwt <WEB3_JWT> -port 3000 -ipfs-gateway-urls "https://w3s.link/ipfs/%s,https://dweb.link/ipfs/%s,https://ipfs.io/ipfs/%s"
./build/bin/server -jwt <WEB3_JWT> -port 3001 -ipfs-gateway-urls "https://w3s.link/ipfs/%s,https://dweb.link/ipfs/%s,https://ipfs.io/ipfs/%s"
```
The `-ipfs-gateways-urls` is a comma separated list of http urls with a `%s` present in it, which is formatted to replace the IPFS content identifier (CID) in it.
2 changes: 1 addition & 1 deletion core/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
// IpfsPinnerVersionMinor is Minor version component of the current release
IpfsPinnerVersionMinor = 1
// IpfsPinnerVersionPatch is Patch version component of the current release
IpfsPinnerVersionPatch = 12
IpfsPinnerVersionPatch = 13
clientIdentifier = "ipfs-pinner" // Client identifier to advertise over the network
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/ipfs/go-block-format v0.1.2
github.com/ipfs/go-cid v0.3.2
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-ipfs-files v0.1.1
github.com/ipfs/go-ipld-format v0.4.0
github.com/ipfs/go-log/v2 v2.5.1
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@ github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqg
github.com/ipfs/go-cid v0.1.0/go.mod h1:rH5/Xv83Rfy8Rw6xG+id3DYAMUVmem1MowoKwdXmN2o=
github.com/ipfs/go-cid v0.2.0/go.mod h1:P+HXFDF4CVhaVayiEb4wkAy7zBHxBwsJyt0Y5U6MLro=
github.com/ipfs/go-cid v0.3.0/go.mod h1:P+HXFDF4CVhaVayiEb4wkAy7zBHxBwsJyt0Y5U6MLro=
github.com/ipfs/go-cid v0.3.2 h1:OGgOd+JCFM+y1DjWPmVH+2/4POtpDzwcr7VgnB7mZXc=
github.com/ipfs/go-cid v0.3.2/go.mod h1:gQ8pKqT/sUxGY+tIwy1RPpAojYu7jAyCp5Tz1svoupw=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
github.com/ipfs/go-cidutil v0.1.0 h1:RW5hO7Vcf16dplUU60Hs0AKDkQAVPVplr7lk97CFL+Q=
github.com/ipfs/go-cidutil v0.1.0/go.mod h1:e7OEVBMIv9JaOxt9zaGEmAoSlXW9jdFZ5lP/0PwcfpA=
github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
Expand Down
2 changes: 1 addition & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
)

func main() {
portNumber := flag.Int("port", 3000, "port number for the server")
portNumber := flag.Int("port", 3001, "port number for the server")
token := flag.String("jwt", "", "JWT token for web3.storage")
ipfsGatewayUrls := flag.String("ipfs-gateway-urls", "https://w3s.link/ipfs/%s,https://dweb.link/ipfs/%s,https://ipfs.io/ipfs/%s", "comma separated list of ipfs gateway urls")

Expand Down

0 comments on commit fc8bd05

Please sign in to comment.