Local Documentation
Purpose
Section titled “Purpose”I like the idea of self hosting and having things accessible even when the internet goes down. Recently I stumbled upon the YouTuber @bashbunni and in one of her videos she mentioned how https://devdocs.io is something you can self host. That piqued my interest to say the least and I decided to do the same myself. This might be the shortest writeup I’ll ever do, but it’s still worth having I think.
Self Host devdocs.io
Section titled “Self Host devdocs.io”So, the easiest way I think to self host devdocs.io is to use docker-compose. I won’t go into detail how to set it up, but this is the docker-compose.yml I created for this:
services: devdocs: image: ghcr.io/freecodecamp/devdocs:latest ports: - 9292:9292Very tiny indeed. I don’t have much more to say, other than this is fantastic.
Self host cheat.sh
Section titled “Self host cheat.sh”Another nice to have is to self host cheat.sh. These are the steps I took to make that happen:
- clone https://github.com/chubin/cheat.sh/
- Bump alpine to
3.18inDockerfile - run
docker-compose up -d
Now, the cool thing about cheat.sh is that the output looks nice even when you curl, so doing curl localhost:8002/echo gives you the output in the terminal. Nifty!
And the last thing I did was to add a function in my .zshrc:
function cheat() { curl localhost:8002/$@}So now when I run cheat echo this is the output:
# echo# Print given arguments.# See also: `printf`.# More information: <https://www.gnu.org/software/coreutils/manual/html_node/echo-invocation.html>.
# Print a text message. Note: Quotes are optional:echo "Hello World"
# Print a message with environment variables:echo "My path is $PATH"
# Print a message without the trailing newline:echo -n "Hello World"
# Append a message to the file:echo "Hello World" >> file.txt
# Enable interpretation of backslash escapes (special characters):echo -e "Column 1\tColumn 2"
# Print the exit status of the last executed command (Note: In Windows Command Prompt and PowerShell the equivalent commands are `echo %errorlevel%` and `$lastexitcode` respectively):echo $?
# Pass text to another program through `stdin`:echo "Hello World" | programNifty huh?