Skip to content

Commit

Permalink
First working version
Browse files Browse the repository at this point in the history
  • Loading branch information
christroutner committed Aug 22, 2022
0 parents commit f5f68c3
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data/
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:22.04
#FROM jrei/systemd-ubuntu:22.04
MAINTAINER Chris Troutner <chris.troutner@gmail.com>

# Work from the /root directory
WORKDIR /root

# Setup the container with required software.
COPY setup-config.sh setup-config.sh
RUN bash setup-config.sh

COPY start-ipfs.sh start-ipfs.sh
CMD ["./start-ipfs.sh"]

# Launch a dummy app to keep the process alive so that I can debug issues.
# This command is overwritten by the docker-compose file.
#COPY dummyapp.js dummyapp.js
#CMD ["node", "dummyapp.js"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# trickle-ipfs

This is a Docker container that wraps go-ipfs/kubo in the [Trickle](https://wiki.archlinux.org/title/trickle) Linux command line app, so that bandwidth consumption can be controlled by the adminstrator.

A quick search for 'bandwidth ipfs' will reveal a lot of frustrated stories of people wanting to use go-ipfs but not being able to control the amount of bandwidth that it uses. This Docker container solve that problem. Bandwidth shaping is controlled by Trickle, which wraps the go-ipfs binary.
5 changes: 5 additions & 0 deletions cleanup-images
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Remove all untagged docker images.
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')

36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is an example docker-compose file that can be used to customize and
# control the IPFS daemon. Things to pay attention to:
# - envrionment
# - volume
# - memory limit
# - ports

version: '3.9'

services:
trickle-ipfs:
image: christroutner/trickle-ipfs:v1.0.0
#build:
# context: ./
# dockerfile: Dockerfile
container_name: trickle-ipfs
environment:
IPFS_DAEMON_ARGUMENTS: '--enable-pubsub-experiment --migrate=true --agent-version-suffix=docker --routing=dhtclient'
UPLOAD_KBPS: '100'
DOWNLOAD_KBPS: '100'
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '10'
mem_limit: 1000mb
ports:
- 4001:4001
- 5001:5001
- 8080:8080
command: [
'./start-ipfs.sh'
]
volumes:
- ./data/go-ipfs:/root/.ipfs
restart: always
11 changes: 11 additions & 0 deletions dummyapp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
A dummy app for keeping a docker container running, so that I log into it
and debug.
*/

"use strict"

setInterval(function() {
const now = new Date()
console.log(`Timestamp: ${now.toLocaleString()}`)
}, 60000)
19 changes: 19 additions & 0 deletions setup-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# This script setups up the Docker image and installed needed software.
# This script assumes its being run by root.

apt-get update
apt-get install -y curl wget nano wget snapd trickle

#Install Node and NPM
#curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
#bash nodesource_setup.sh
#rm nodesource_setup.sh
#apt-get install -y nodejs build-essential

# Install IPFS
wget https://dist.ipfs.io/go-ipfs/v0.14.0/go-ipfs_v0.14.0_linux-amd64.tar.gz
tar -xvf go-ipfs_v0.14.0_linux-amd64.tar.gz
rm go-ipfs_v0.14.0_linux-amd64.tar.gz
/root/go-ipfs/install.sh
7 changes: 7 additions & 0 deletions start-ipfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# This bash script file starts IPFS with arguments passed from the
# docker compose file.

ipfs init --profile=server
trickle -s -u $UPLOAD_KBPS -d $DOWNLOAD_KBPS ipfs daemon $IPFS_DAEMON_ARGUMENTS

0 comments on commit f5f68c3

Please sign in to comment.