A service to replicate and serve requests for site configurations based on site ID, public IP, and the on-site lead contact's OTP.
Révision | 555d6c996ec69b44b0e4ace4d9c7423bf0f0709a (tree) |
---|---|
l'heure | 2021-10-11 22:11:59 |
Auteur | Sean Seago <seanseago@duck...> |
Commiter | Sean Seago |
Added go-ipfs docker to try IPFS as a storage backend.
@@ -0,0 +1,33 @@ | ||
1 | +FROM golang:1.16-alpine | |
2 | + | |
3 | +# This is set in the CI as well, be sure to update in both places | |
4 | +ARG IPFS_TAG="v0.10.0" | |
5 | + | |
6 | +ENV SRC_DIR /go/src/github.com/ipfs/go-ipfs | |
7 | + | |
8 | +RUN apk add --no-cache git make bash gcc musl-dev \ | |
9 | + && go get -u github.com/whyrusleeping/gx | |
10 | + | |
11 | +# Fixes an issue with symlinked binaries not playing well with musl | |
12 | +# Thanks https://stackoverflow.com/questions/34729748/installed-go-binary-not-found-in-path-on-alpine-linux-docker | |
13 | +RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 | |
14 | + | |
15 | +RUN git clone --branch $IPFS_TAG https://github.com/ipfs/go-ipfs.git $SRC_DIR \ | |
16 | + && cd $SRC_DIR \ | |
17 | + && make build | |
18 | + | |
19 | +FROM alpine:latest | |
20 | + | |
21 | +RUN apk add --no-cache bash | |
22 | + | |
23 | +ENV SRC_DIR /go/src/github.com/ipfs/go-ipfs | |
24 | +COPY --from=0 $SRC_DIR/cmd/ipfs/ipfs /usr/local/bin/ipfs | |
25 | + | |
26 | +COPY ./start_ipfs.sh / | |
27 | + | |
28 | +EXPOSE 4001 8080 5001 | |
29 | + | |
30 | +ENTRYPOINT ["/start_ipfs.sh"] | |
31 | + | |
32 | +CMD ["daemon", "--migrate"] | |
33 | + |
@@ -0,0 +1,42 @@ | ||
1 | +#! /bin/bash | |
2 | + | |
3 | +set -e | |
4 | + | |
5 | +# Detect custom IPFS_PATH configurations | |
6 | +if [[ -z "$IPFS_PATH" ]]; then | |
7 | + IPFS_PATH="/root/.ipfs" | |
8 | +fi | |
9 | + | |
10 | +# Initialize IPFS if path is empty | |
11 | +if [ -z "$(ls -A $IPFS_PATH 2> /dev/null)" ]; then | |
12 | + ipfs init | |
13 | + ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 | |
14 | +fi | |
15 | + | |
16 | +# If the CIDS_TO_PIN variable is not supplied let ipfs take over the process | |
17 | +if [ -z $CIDS_TO_PIN ]; then | |
18 | + echo "received no CIDS_TO_PIN" | |
19 | + exec ipfs "$@" | |
20 | +fi | |
21 | + | |
22 | +# Otherwise spawn a daemon, pin, kill the daemon, start IPFS | |
23 | + | |
24 | +# Start an ipfs daemon | |
25 | +ipfs daemon --migrate & | |
26 | + | |
27 | +# Store the PID so we can kill it later | |
28 | +DAEMON_PID=$(echo $!) | |
29 | + | |
30 | +# Wait for the daemon to initialize | |
31 | +sleep 10 | |
32 | + | |
33 | +# Pin all the supplied cids | |
34 | +for CID in $CIDS_TO_PIN; do | |
35 | + echo "pinning $CID" | |
36 | + ipfs pin add --progress $CID | |
37 | +done | |
38 | + | |
39 | +kill $DAEMON_PID | |
40 | + | |
41 | +exec ipfs "$@" | |
42 | + |