commit 005f749d0a7fce7cad78e2a9af9648d90eb89de0 Author: tornadocontrib Date: Sun Jul 7 06:37:29 2024 -0700 IPFS builder diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e6781e7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# Dockefile from https://notes.ethereum.org/@GW1ZUbNKR5iRjjKYx6_dJQ/Bk8zsJ9xj +# FROM node:20.15.0-bullseye-slim +FROM node@sha256:8f6881869150049f8f1228a2f828c3dc1d0a012f136175f02ae46a83c0a1002b + +# install wget, git and necessary certificates so we can install IPFS below +RUN apt update && apt install --yes --no-install-recommends wget git apt-transport-https ca-certificates && rm -rf /var/lib/apt/lists/* + +# install IPFS +WORKDIR /home/root +RUN wget -qO - https://dist.ipfs.tech/kubo/v0.29.0/kubo_v0.29.0_linux-amd64.tar.gz | tar -xvzf - \ + && cd kubo \ + && ./install.sh \ + && cd .. \ + && rm -rf kubo +RUN ipfs init + +ENV GIT_REPOSITORY=https://git.tornado.ws/tornadocash/classic-ui.git +# From development branch, double check with tornado.ws +ENV GIT_COMMIT_HASH=57d3ba5ac5ea8bab6e24b30630c933568dddbec9 + +# clone the repository +RUN mkdir /app/ + +WORKDIR /app + +# Simple hack to fetch only commit and nothing more (no need to download 1GB sized repo, only 100MB would be enough) +RUN git init && \ + git remote add origin $GIT_REPOSITORY && \ + git fetch --depth 1 origin $GIT_COMMIT_HASH && \ + git checkout $GIT_COMMIT_HASH + +# install, build and prep for deployment +RUN yarn install --frozen-lockfile --ignore-scripts +RUN yarn build:lts +RUN yarn generate:lts + +# add the build output to IPFS and write the hash to a file +RUN ipfs add --cid-version 1 --quieter --only-hash --recursive ./dist > ipfs_hash.txt +# print the hash for good measure in case someone is looking at the build logs +RUN cat ipfs_hash.txt + +# this entrypoint file will execute `ipfs add` of the build output to the docker host's IPFS API endpoint, so we can easily extract the IPFS build out of the docker image +RUN printf '#!/bin/sh\nipfs --api /ip4/`getent ahostsv4 host.docker.internal | grep STREAM | head -n 1 | cut -d \ -f 1`/tcp/5001 add --cid-version 1 -r ./dist' >> entrypoint.sh +RUN chmod u+x entrypoint.sh + +ENTRYPOINT [ "./entrypoint.sh" ] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..75ac83d --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Tornado Cash IPFS Builder + +(Possibly) Deterministic IPFS hash generation script for Tornado UI + +Works on any platform (Linux, Windows, MacOS) if the Docker Desktop is installed. + +## TL;DR + +IPFS hash based on commit `57d3ba5ac5ea8bab6e24b30630c933568dddbec9` (from development branch https://git.tornado.ws/tornadocash/classic-ui/src/branch/development): + +`bafybeif___________________________________________rtpvvs5y` (hash masked, you should produce your own!) + +Script based on https://notes.ethereum.org/@GW1ZUbNKR5iRjjKYx6_dJQ/Bk8zsJ9xj + +This script is provided as-is and should be only used as an example to derive possibly deterministic IPFS contenthash and shouldn't be trusted as a whole. + +Again, this script DOES NOT guarantee deterministic IPFS builds since the process could be easily broken as it depends on many external libraries (like kubo, wget, or docker) and external links that could be censored and broken anytime. + +By using this script you should FULLY UNDERSTAND what each line does and shouldn't blindly trust the generated output. What this script could achieve is to demonstrate how Tornado UI could be built and added on IPFS at convenience. + +## How to use + +1. Build the docker image + +```bash +docker build -t tornado-classic-ui . +``` + +2. Check the generated IPFS hash + +```bash +docker container run --rm -it --entrypoint cat tornado-classic-ui /app/ipfs_hash.txt +``` + +## (Optional) Add built UI to IPFS Desktop + +First, install the latest IPFS Desktop. + +Then, build the docker image and run the following command + +```bash +docker container run --rm tornado-classic-ui +``` + +You can now access the UI on your local IPFS gateway through the following + +http://localhost:8080/ipfs/content_hash_here \ No newline at end of file