├── README.md ├── docker ├── Dockerfile └── start ├── install.sh └── kubernetes └── ipfs-gateway.deployment.yaml /README.md: -------------------------------------------------------------------------------- 1 |

2 |

3 | ipfs 4 |

5 |

6 | + 7 |

8 |

9 | caddy 10 |

11 |

12 | --- 13 | 14 | # IPFS-Gateway 15 | 16 | The idea behind this project is to make tools/guides/etc to facilitate the process of making it easy to spin up your own ipfs gateway. It heavily relies on features of Caddy. 17 | 18 | 19 | ## Features 20 | 21 | - Easy setup via docker or kubernetes 22 | - Automatic HTTPS via Caddy 23 | - Mount volume at `/data` for persistence. 24 | 25 | ## Docker Quickstart 26 | 27 | Run this: 28 | 29 | ```docker run -d -e CADDYHOST=example.com -v `pwd`/data:/data -p 80:80 -p 443:443 --name ipfs-gateway cbluth/ipfs-gateway:latest``` 30 | 31 | In order for https to work, your host needs to be accessible on port 443 (hard requirement), and you need to set the `CADDYHOST` environment variable. If you do not want https, then do not set `CADDYHOST`. 32 | 33 | 34 | 35 | ## TODO 36 | 37 | - Option to register ipfs-gateway on a public list 38 | - Use `install.sh` to install locally. 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM ubuntu:latest 3 | 4 | USER root 5 | ENV IPFS_DIST_URL=https://dist.ipfs.io/go-ipfs/v0.4.10/go-ipfs_v0.4.10_linux-amd64.tar.gz \ 6 | CADDY_DIST_URL=https://caddyserver.com/download/linux/amd64?plugins=http.cache,http.cors,http.ipfilter \ 7 | IPFS_PATH=/data/ipfs \ 8 | CADDYPATH=/data/caddy 9 | 10 | 11 | RUN apt-get update ;\ 12 | apt-get dist-upgrade -y ;\ 13 | apt-get install -qy wget 14 | 15 | RUN mkdir -p ~/tmp ;\ 16 | wget -qO- ${IPFS_DIST_URL} | tar xz -C ~/tmp/ ;\ 17 | mv ~/tmp/go-ipfs/ipfs /usr/local/bin/ ; rm -rf ~/tmp/* 18 | 19 | RUN wget -qO- ${CADDY_DIST_URL} | tar xz -C ~/tmp/ ;\ 20 | mv ~/tmp/caddy /usr/local/bin/ ; rm -rf ~/tmp/* 21 | 22 | RUN ipfs --version ; caddy --version 23 | 24 | COPY start / 25 | EXPOSE 8080 26 | 27 | # ENTRYPOINT /run 28 | CMD /start -------------------------------------------------------------------------------- /docker/start: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | IPFS_PATH=/data/ipfs 4 | CADDYPATH=/data/caddy 5 | CADDYFILE="${CADDYPATH}/Caddyfile" 6 | CADDYHOST=${CADDYHOST:-":80"} 7 | 8 | mkdir -vp ${IPFS_PATH} ${CADDYPATH} 9 | 10 | if [ ! -e "${IPFS_PATH}/config" ]; then 11 | ipfs init 12 | fi 13 | 14 | cat << ! > ${CADDYFILE} 15 | ${CADDYHOST} { 16 | gzip 17 | cors 18 | cache 19 | proxy / http://localhost:8080/ { 20 | transparent 21 | } 22 | } 23 | 24 | ! 25 | 26 | echo "starting ipfs..." ; sleep 1 27 | /usr/local/bin/ipfs daemon --writable & 28 | echo "starting caddy..." ; sleep 1 29 | /usr/local/bin/caddy -log stdout -agree=true -conf=${CADDYFILE} -root=/var/tmp & 30 | 31 | while true ; do 32 | sleep 2 33 | 34 | # check for ipfs 35 | ps awux | grep [/]usr/local/bin/ipfs > /dev/null 36 | if ! [ $? -eq 0 ] ; then 37 | echo "ipfs not running, closing..." 38 | break ; fi 39 | 40 | # check for caddy 41 | ps awux | grep [/]usr/local/bin/caddy > /dev/null 42 | if ! [ $? -eq 0 ] ; then 43 | echo "caddy not running, closing..." 44 | break ; fi 45 | 46 | done 47 | 48 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ENV IPFS_DIST_URL=https://dist.ipfs.io/go-ipfs/v0.4.10/go-ipfs_v0.4.10_linux-amd64.tar.gz 4 | CADDY_DIST_URL=https://caddyserver.com/download/linux/amd64?plugins=http.cache,http.cors,http.ipfilter 5 | IPFS_PATH=/data/ipfs 6 | CADDYPATH=/data/caddy 7 | 8 | mkdir -p ~/tmp 9 | wget -qO- ${IPFS_DIST_URL} | tar xz -C ~/tmp/ 10 | mv ~/tmp/go-ipfs/ipfs /usr/local/bin/ 11 | wget -qO- ${CADDY_DIST_URL} | tar xz -C ~/tmp/ 12 | mv ~/tmp/caddy /usr/local/bin/ 13 | 14 | ipfs --version 15 | caddy --version 16 | 17 | # TODO -------------------------------------------------------------------------------- /kubernetes/ipfs-gateway.deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: ipfs-gateway 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | app: ipfs-gateway 11 | spec: 12 | containers: 13 | - name: ipfs-gateway 14 | image: cbluth/ipfs-gateway:latest 15 | 16 | --------------------------------------------------------------------------------