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

Dockerize the development environment #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/.idea/
/node_modules
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Swagger (v2) and OpenAPI (v3) are specification for describing an API. Writing a

You can import the yaml/json file in the [Swagger editor](http://editor.swagger.io/) and generate a client for any [supported languages](https://swagger.io/open-source-integrations/).

#Development
```
docker-compose up -d --build
```

Connect to [http://localhost:8888]([http://localhost:8383])

## License

IPFS OpenAPI is under the [MIT License](LICENSE.md).
Expand Down
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.2'

services:
ipfs:
image: jbenet/go-ipfs
volumes:
- ./docker/ipfs/start_ipfs.sh:/usr/local/bin/start_ipfs
- ./docker/ipfs/config_ipfs.sh:/usr/local/bin/config_ipfs
ports:
- 5001:5001
- 4001:4001
- 8080:8080
expose:
- 5001
- 4001
- 8080

editor-synced:
image: lepetitbloc/swagger-editor:latest
ports:
- 8888:8080
- 3000:3000
- 3001:3001
volumes:
- ./spec:/usr/share/nginx/html/data/
7 changes: 7 additions & 0 deletions docker/ipfs/config_ipfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
Copy link
Member

Choose a reason for hiding this comment

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

Why did you choose this method over the ipfs config file one?
That's shame we have to modify two bash scripts, whereas using a config file seems to be built-in in the start script shipped with the container.

ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["GET","POST","PUT"]'

42 changes: 42 additions & 0 deletions docker/ipfs/start_ipfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
set -e
user=ipfs
repo="$IPFS_PATH"

if [ `id -u` -eq 0 ]; then
echo "Changing user to $user"
# ensure folder is writable
su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo"
# restart script with new privileges
exec su-exec "$user" "$0" "$@"
fi

# 2nd invocation with regular user
ipfs version

if [ -e "$repo/config" ]; then
echo "Found IPFS fs-repo at $repo"
else
ipfs init
fi

# if the first argument is daemon
if [ "$1" = "daemon" ]; then
# filter the first argument until
# https://github.com/ipfs/go-ipfs/pull/3573
# has been resolved
shift
else
# print deprecation warning
# go-ipfs used to hardcode "ipfs daemon" in it's entrypoint
# this workaround supports the new syntax so people start setting daemon explicitly
# when overwriting CMD
echo "DEPRECATED: arguments have been set but the first argument isn't 'daemon'" >&2
echo "DEPRECATED: run 'docker run ipfs/go-ipfs daemon $@' instead" >&2
echo "DEPRECATED: see the following PRs for more information:" >&2
echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3573" >&2
echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3685" >&2
fi

config_ipfs
exec ipfs daemon "$@"
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "ipfs-swagger",
"version": "1.0.0",
"description": "**IPFS** Rest API swagger specification document in Yml and Json (OpenAPI).",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"start": "browser-sync start --config bs-config.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/LePetitBloc/ipfs-swagger.git"
},
"keywords": [
"ipfs",
"swagger",
"swagger-editor",
"docker"
],
"author": "JulesAaelio",
"license": "ISC",
"bugs": {
"url": "https://github.com/LePetitBloc/ipfs-swagger/issues"
},
"homepage": "https://github.com/LePetitBloc/ipfs-swagger#readme",
"devDependencies": {
"browser-sync": "^2.24.5"
}
}
Empty file added spec/swagger.yml
Empty file.