Back
Nathan Wailes
Nathan Wailes
PRO
PRO
@nathanwailes
Full-stack dev, 180 on the LSAT. Work habit goal: bit.ly/3hb8fdk i.imgur.com/e9b6bqw.png Productivity thoughts: shorturl.at/grcs8
57
Joined October 2020
Load previous page…
Worked on getting ChatGPT working with the Line echo bot example...created a separate file to test the OpenAI API call...hit an error, turned out I needed to pay separately for API credits...hit another error from my request not being formatted properly...finally got it working, now I need to try to integrate it with the Line echo bot...updated the code to use the ChatGPT code and deployed it, but the bot isn't responding anymore, I need to examine the logs...checked the logs with `dokku logs api` (`api` being the name of my app) and saw the error: "You didn't provide an API key."...need to add my API key as an env var...got that added with `dokku config:set`...tested the echo bot again and IT WORKED. It is insane insane insane how fast I can get stuff working when I can ask ChatGPT for help at every step to cut through all the usual Googling to figure out how to do something...next up, hmm, I'm not sure, either work on an accompanying Vue frontend or try fleshing out the bot to handle the particular use-case I have in mind...sent an email to another YouTuber to see if I can do a video with him.
Spent an hour reading some of [the backend code][1] for a Go / Vue chat app I saw posted to Reddit, as a way of trying to build familiarity with how my Go / Vue projects should be structured / work.
[1]: github.com/wizzldev/backend/
Struggled to incorporate the Line "echo bot" code into my existing Huma Go backend framework code, so I just YOLO'd it and copied the example code into my `main.go` for the purpose of seeing if I can get it working...ran into an error when pushing to Dokku, it seems to be because I didn't set the Line-related env variables before pushing...set those vars on my Dokku server...clicked the Line 'Verify' button for the callback URL and got a 404, so I now need to look into what happened...I think the issue is that the echo bot code assumes I'll use the DefaultServeMux, but I'm actually using a chi Mux. The key line difference is `log.Fatal(http.ListenAndServe(":"+port, r))`, where the example has `nil` instead of `r`...YOLO'd it again by just disabling the router I had gotten working, just to see if the webhook will work, and got a Success when I clicked the Verify button...next up is to either clean up this mess I've made in my code or keep pushing forwards and try to get the ChatGPT part working.
Destroyed my other two Digital Ocean droplets, I now only have the one $6/mo Dokku droplet...told ChatGPT what I'm trying to achieve with this Line+ChatGPT bot and what I already have working, to get some help visualizing how I should proceed...created a Line developer account...enabled the Messaging API...added the Line Go SDK to my Go backend...next up: I think I want to read the example code provided by Line and ChatGPT and figure out how I can fit it into my existing backend code. I think getting the Line "Echo" bot working in my app would be a good next step. Lowered my phone's daily limit for Twitter and Reddit from 60 mins each to 45 mins each.
Spent an hour going over my app ideas to try to decide on what to work on next, settled on trying to build a Line+ChatGPT bot that will run on my Dokku droplet.
Sent an email to a local YouTuber asking if I can do a video with him as a step towards doing some more personal brand marketing.
Went through my Google Tasks notes-to-myself of stuff it would be cool to make, turned my favorites into Jira projects, and removed them from Google Tasks. Next: pick one and try to come up with a summary of how an MVP could work. Removed links from WhatDo homepage for projects that don't exist (yet). Feeling super happy I set up Netlify / Dokku now that I can just push and have my changes immediately live. Spent time drafting an email to ask a YouTuber if I can do a video with him, I'm on the fence about whether I should do it.
Spent an hour trying to figure out what I should work on next.
Finally got Dokku working with my frontend. Documented my issues here: github.com/dokku/dokku/issues… Tomorrow: figure out what to do next. Maybe look at my Google Tasks, old Trello, etc.
Continuing to try to get my dokku API to work, looking into an `ERR_CONNECTION_REFUSED` error. I posted for help on the dokku github: github.com/dokku/dokku/issues… I suspect the issue may be caused by my not having SSL set up but I'm not sure. I can't even find the logs where the refused connection is being logged.
Continuing to look into the CORS error I'm getting when my frontend tries to make an API request to my backend; it seems my backend dokku app wasn't deployed for some reason; destroyed my existing go dokku app and recreated it and then struggled with an error for a while before realizing I had the same issue a few days ago and the solution was to run `dokku builder:set backend-app build-dir backend`; now getting an error saying the download for my specified version of Go is "unknown to the buildpack"; after much trial-and-error I realized the problem was that Dokku has a stupid error message that makes it sound like it has already automatically chosen a Go buildpack when in fact it has not. I was additionally getting confused because I was seeing Dokku installing Go and not realizing that was because of my +heroku instruction in my go.mod file rather than Dokku automatically using a Go buildpack. The solution was to specify a Go buildpack for my app with `dokku buildpacks:add <my-app> heroku/go`. Now getting a new error: "Failed to connect to database". Fixed it by switching my code to use the `DATABASE_URL` environment variable that Dokku creates for your code to connect to the db. My `git push dokku main` finally succeeded, but I'm still getting a CORS error. Eventually figured out it was because my Dokku app name was `whatdo-backend` when I had forgotten that that would also be the name of the subdomain, so I had to delete the app and recreate it with the name `api`. I also created a `/ping` health-check URL to help me debug this more quickly. I'm now getting a 521 error, I think maybe because Dokku is running on http and Cloudflare is reaching out via https?
Ordered a FocusCap visor model b/c people walking by when I'm working in public is the most distracting thing for me right now: focuscap.io/products/focuscap ; bought a $7 baseball cap to use while I wait, I keep it pulled down low over my eyes and it's probably 90% as good. Verified that for local development my Go backend seems to be able to talk to my Vue frontend with the new way of having the API at a different domain instead of at /api/. Added the new env variable that stores the domain of the API to my Netlify setup and tried using the app, and got an "ERR_NAME_NOT_RESOLVED", realized I hadn't set up a Cloudflare A record for the 'api' subdomain to point to my Digital Ocean / Dokku droplet. After ~20 mins that error went away and it switched to a CORS error. Added my domain to my backend code as an allowed origin for CORS purposes.
Got my frontend app deployed to Netlify, it was surprisingly easy. Changed my Cloudflare DNS settings for the domain to point to Netlify, and turned off the 'Proxy' setting in Cloudflare. Changed my frontend and backend code to use the new setup of having the api at a different domain instead of at `/api/` at the same domain. Tomorrow I'll need to test that local development is still working properly and then see if I can get it working on Netlify/DigitalOcean.
Continuing to try to get Dokku working with a monorepo; I think I got past my last problem of how to deploy both apps by running on the server `dokku builder:set backend-app build-dir backend` (and similar for the frontend); now I'm seeing a new error when I try to deploy the frontend app: `Two different lockfiles found: package-lock.json and yarn.lock`; I seemed to fix it by deleting the yarn.lock. New error: "Missing script: start"; fixed that by adding a 'start' entry to my package.json. New error: "Cannot find module '@vitejs/plugin-vue'"; maybe because it's listed as a devDependency? I found this SO post where the guy said he ended up just putting his frontend on Netlify, so maybe I'll try that instead: stackoverflow.com/a/62455021/… ChatGPT is saying the way to do it is to deploy my API at api.mydomain.com and then direct traffic at other subdomains to Netlify to handle frontend requests. So I'll try that tomorrow.
Hit an error when trying to deploy the dokku app, I think it's because I have both a frontend dir and a backend dir in my repo. I think the next step is to try to follow the example of this github repo to deploy two separate dokku apps: github.com/abulte/dokku-simpl…
My next goal is to get postgres working locally instead of sqlite b/c apparently it's easier to use postgres on dokku(?). Installed postgres on my macbook using postgresapp.com, it was so easy 😭 Connected GoLand to a new postgres db for my backend; got my backend code working with the postgres db; committed and pushed my code. Next step is to continue with this guide: shellbear.me/blog/go-dokku-de…
Finally got the Dokku Ruby on Rails example app working 😭 Apparently I just needed to reboot the droplet? `curl` to my droplet's IP wasn't working, `dokku ports:list ruby-getting-started` didn't show it listening on port 80, `dokku ports:add ruby-getting-started http:80:5000` resulted in an error saying nginx wasn't running. Rebooting seemed to fix it. Next up is trying to deploy my Go backend with Dokku. Destroyed the ruby demo dokku app. Resized my DO droplet to the $6/mo one.
Continuing to try to get the dokku example app working. I'm getting an error when I visit saying "Web server is down" but it's not clear to me where to look for additional information about what exactly the problem is. The Digital Ocean logs for the subdomain app don't show any errors or even requests.
Looking into why the dokku example site isn't loading when I visit the URL in my browser. I had to add an A record for the subdomain in Cloudflare. But I'm now getting a message saying there's a host error, while dokku's logs don't show any issues (or apparently even any requests at all). I'm wondering if this is maybe SSL related. Deleted DNS records from Digital Ocean for domains I have DNS records for in Cloudflare.
Looking into why `git push dokku main` didn't work. After much Googling, it was because my $5/mo 1 GB droplet didn't have enough RAM to build the Ruby on Rails demo app. So my plan is to use the $12/mo droplet to get the demo working and then try to downgrade to the $5/mo droplet when I switch to trying to use Dokku with my Go backend.