This is my own personal CDN written in GO and Svelte using DigitalOceans Spaces.
Anthony's repository as I would have been lost with DigitalOcean, Firebase and other things without it: https://github.com/acollierr17/cdn
This uses Make to make it easier to build the frontend and backend into a folder.
You are not required to use Make if that's what you prefer, simply execute commands in the build
rule.
Build the frontend using yarn build
inside of the client
folder, it'll output the built files into public/build
Golang by default builds to the current operating system, if you would like to build for Windows or Linux then you need to set the GOOS
environment variable (check GOOS examples).
You can find more information about this here: https://www.digitalocean.com/community/tutorials/building-go-applications-for-different-operating-systems-and-architectures
Then build the executable using go build
, by default it'll output in the current directory, if you want it elsewhere you'll need to use the -o
option with a directory.
Unix:
GOOS=linux
Windows PowerShell:
$env:GOOS = "linux"
To connect to a Firebase App you will need the authentication file service-account.json
in the current directory.
For DigitalOcean Spaces you will need to add the necessary info that start with SPACES
in the .env file, which should also be in the current directory.
More explanation of the rest of the environment variables:
CDN_ENDPOINT
is your site endpoint, such as https://cdn.mysite.com
AUTHORIZATION
is the main authorization token, this should be kept as anyone will be able to upload and delete files through the site.
Server routes
Dashboard