Digital Ocean Authentication & Site Setup

I recently took the time to set up my website again after a long break from writing. The setup I used as a stopgap solution involved using my static site generator to generate HTML files from markdown, check the resulting HTML into a git repository, and push that second git repository up to GitHub, which Digital Ocean's static site app platform would parse and serve from. Obviously, taking things from one git repository and dropping them in another git repository is not the right way to do things. To fix all this jank, I wanted to set things up using Digital Ocean's container registry and container platform so that I could just build a container image, push it up, and have my site deploy from that image instead of relying on static files that are checked in somewhere. This approach works great, but I ran into two major issues: first with authenticating and then a more fun DNS propagation issue.

Docker Authentication

The first problem I ran into was getting my local Docker to push the container I'd built into the container registry. They'll tell you to use their own command in the documentation, and when it works, it's very slick . Supposedly, that tool can get your Docker CLI authenticated if you generate an API key and log into the tool and run doctl registry login. Unfortunately, that never worked for me. It would claim success and modify some files in my dotfiles, but it wouldn't actually allow me to run docker push [image-name]. Fortunately, there is more than one way to skin a cat . I had to generate an API key in Digital Ocean, then run docker login [url] and provide the API key as both the user name and the password. I have a sneaking suspicion that this might have some security implications, so your mileage may vary, but it's the only way I got it to work for me.

But My Container Still Didn't Work

After solving those issues, I still couldn't access my container. I briefly fiddled in the app's settings and realized that the HTTP port in the app spec (a weird YAML-based configuration for Digital Ocean apps ) was wrong. While updating the app spec did allow my build to pass, I still got a 404 error when I hit the app's URL. After trying a bunch of things to expose different ports, I decided it was getting late and I needed to turn in for the night. Infuriatingly, after coming back to it the next day, I realized my app was working perfectly ... and I'm pretty sure my DNS records just hadn't propagated yet . The takeaway? Always try to hit the IP of your server instead of hitting the domain. Even the service-generated domains provided by your host will need to propagate like any other domain name.

Update on authentication issues

I had to set up my desktop (and not just my laptop) to be able to work and I realized what my authentication problem was. I needed to run doctl auth init as sudo since I am not using Docker without root. Then I could run sudo doctl registry login and everything started working. I could have sworn I had tried that before, but this fixed it for my desktop!


I am currently in the process of building my own static site generator! You can follow progress on that project here