Skip to content

Commit 08e6ba2

Browse files
committed
Script to start IPFS daemon with Docker
1 parent cab4cd0 commit 08e6ba2

File tree

7 files changed

+65
-41
lines changed

7 files changed

+65
-41
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,8 @@ You can submit bug reports using the
208208

209209
### Setting up a local development environment
210210

211-
1. [Install and configure a local IPFS server](tools/ipfs/README.md):
212-
2. Follow the instructions in the (Python) tox documentation to install the `tox` Python environment runner:
213-
https://tox.readthedocs.io/en/latest/install.html
211+
1. [Install tox](https://tox.readthedocs.io/en/latest/install.html)
212+
2. [Install a local IPFS server](tools/ipfs/README.md):
214213
3. Clone the GIT repository if you haven't already:
215214
`git clone https://github.com/ipfs-shipyard/py-ipfs-http-client.git`
216215

@@ -236,19 +235,14 @@ make sure that your code passes both the
236235

237236
As well as the tests:
238237

239-
1. Start IPFS server (do this once in a separate terminal):
240-
241-
$ ./tools/ipfs/run.sh
242-
243-
2. Execute unit and functional tests:
244-
245238
$ tox -e py3 -e py3-httpx
246239

247240
If you are unsure, don't hesitate to just submit your code, and a human will
248241
take a look. 🙂
249242

250-
If you can, Please make sure to include new unit tests for new features or
251-
changes in behavior. We aim to bring coverage to 100% at some point.
243+
Please make sure to include new unit tests for new features or
244+
changes in behavior.
245+
252246

253247
#### Installing the pre-commit Hook
254248

tools/ipfs/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ipfs/go-ipfs:v0.8.0
2+
3+
RUN sed -i 's/exec ipfs "$@"//' /usr/local/bin/start_ipfs
4+
ADD entrypoint.sh /
5+
6+
ENTRYPOINT ["/entrypoint.sh"]
7+
CMD ["ipfs", "daemon", "--migrate=true", "--enable-namesys-pubsub"]

tools/ipfs/README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
11

2-
# Local IPFS Server
2+
# Running Tests
33

4-
`py-ipfs-httpclient` requires a live local server to run its
5-
functional tests.
4+
Tests are primarily run from the command line using a locally installed IPFS server.
65

7-
## Installation
6+
Alternatively, you can launch the IPFS daemon with Docker and run tests from your IDE.
87

9-
To install it, follow the [official instructions](https://docs.ipfs.io/install/command-line/),
10-
then finish with some [local configuration](configure.sh):
118

12-
$ ./configure.sh
9+
## Local IPFS Server Installation
1310

14-
The above script is run once after installing.
11+
To install it, follow the [official instructions](https://docs.ipfs.io/install/command-line/).
1512

16-
## Running Tests
13+
Remaining configuration is applied by [run_tests.py](../../test/run-tests.py) on each run.
14+
15+
16+
## Running Tests Using Local Installation From Command Line
17+
18+
* `tox -e py3`
19+
* `tox -e py3-httpx`
20+
21+
22+
## Running Tests Using Docker from IDE (e.g. PyCharm)
23+
24+
1. Start [daemon.sh](daemon.sh)
25+
2. Run `pytest` tests from your IDE as your normally would
26+
27+
You can keep the Docker container running across multiple
28+
executions of the functional test suite.
29+
30+
31+
## Running Tests Without Live Server
1732

1833
You can run unit tests without a live server; `pytest` will skip
1934
over the functional tests when our fixtures detect the server
2035
isn't running.
2136

22-
In a separate terminal, start IPFS with:
2337

24-
$ ./run.sh
38+
## pytest-docker Plugin
39+
40+
While `pytest-docker` supports running functional tests against a
41+
Docker container using Docker Compose, it is not supported on
42+
Windows or Mac with Travis and IPFS.
2543

26-
Stop it with Ctrl+C. You can keep it running across multiple
27-
executions of the functional test suite.

tools/ipfs/configure.sh

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

tools/ipfs/daemon.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
tag=py-ipfs-http-client-daemon:latest
6+
7+
docker build -t $tag .
8+
docker run --rm -p 4001:4001 -p 5001:5001 -p 8080:8080 $tag
9+

tools/ipfs/entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Only does configuration; doesn't start the daemon
6+
/usr/local/bin/start_ipfs
7+
8+
echo "Enabling experimental features"
9+
10+
ipfs config --json Experimental.FilestoreEnabled true
11+
12+
echo "Enabled experimental features"
13+
14+
# Start the daemon (unless other args provided)
15+
exec "$@"

tools/ipfs/run.sh

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

0 commit comments

Comments
 (0)