Full stack part 1: Some thoughts on online tutorials
Ok, so just to let you know, we’ll not get very far in this first part! It’s all about the journey after all.
Some background
I’ve gone through lots of steps, lots of youtube tutorials, lots of written tutorials, on many many subjects regarding development. There’ve been lots of error messages, obstacles etc. already, but I didn’t start writing this tutorial, or maybe just a non-tutorial journey of my own personal development process, until now; I have forgotten or can’t find the various error messages now.
This will be slightly backwards at times, but here’s a short list of what I intend to cover:
- Setting up some of the development environment
- Back-end written in Go
- Front-end in Svelte / SvelteKit
- Authentication with JWT
- Authentication with Google and maybe others
- Deployment
So it is pretty much going to cover most things from start to finish. I’m coding on a Windows machine, and I have Ubuntu-20.04 running with WSL2. I am using VS Code to write code, and there’s various extensions installed. That said, those are not requirements, and I’ve set them up a while back and can’t really remember what was involved. There’ll be some tutorials about it. I also have Docker desktop installed.
Docker and database
So, as I just started writing this, and I’m in the process of going through yet another tutorial, just so happens, it’s started with a need for a database. I have some old LAMPs running in Docker, but I can’t remember what it’s for, or how to access it, so what I’ve done is googled docker mysql and docker phpmyadmin
and I’ve come across the following three places - keep in mind that things develop fast, my commands below may differ from the working ones in a few weeks time from the time of writing. For now, these worked for me. But first, let’s see the links:
How to get mysql running in Docker - go to the Docker official mysql page and follow instructions: https://hub.docker.com/_/mysql
So I opened my terminal (in my Ubuntu side, but not sure it matters much):
docker run --name gen-mysql-latest-rootroot -e MYSQL_ROOT_PASSWORD=root -d mysql:latest`
The run command pulls image, installs and runs it. So it’s somewhat short hand. I’ve given name, and password (username is root - you can define other users/passwords later). I’ve specified latest
as version, but that’s not always the best necessarily. I’m just testing locally, so it’s ok. You could specify other things like port etc., but I’ve gone with what was on the docker page. It’ll take a minute, but you’ll have mysql running shortly.
Ok, next I went to get phpmyadmin:
https://hub.docker.com/_/phpmyadmin
There’s instructions there and I guess it’s obvious, but I was worried I’ll not link the running mysql instance correctly to the phpmyadmin, so I did a few more searches, took a while and then I found this one: https://www.section.io/engineering-education/containerizing-mysql-server-phpmyadmin-with-docker/
So that looks like it’s a few years old, but I thought it looked promising and scanned through the text. Following the sample commands there, I ran another docker run command:
docker run --name phpmyadmin --link gen-mysql-latest-rootroot:db -p 8068:80 -d phpmyadmin
And after a while, I had phpmyadmin also running. Then I opened http://localhost:8068/ , put root as username and password and was in! All this without errors to my surprise. At this point there’s usually some serious googling going on already.
PostGres
If you go with PostGres database, I’ve done that a while back too with the following command:
docker run --name mydb-postgres -e POSTGRES_PASSWORD=mypassword -p 5432:5432 -d postgres
You should check the docker page first though. You’ll need to install something like PgAdmin4 to access the database with a GUI, as phpmyadmin is for mysql databases.
As you can tell, this is not a docker tutorial, I’m trying to keep commands to minimum, and I’m not building a setup where you’d write dockerfile or use docker compose to keep the whole development environment ready to go in a github repository. Although that would probably be good. And never say never, this is only the first blog post in this series. But if you develop in a team or in various locations, then that’s something you’ll need to have a look at. In short, you’ll have a file with docker commands, and every time you need to set the environment up, you’ll just run the docker setup. But as it gets a bit more complicated from there, that’s now the place I’ll probably say it’s out of scope of this tutorial - ever heard that one before?!?. Do this at home, just once, and we’re going to get something done without any more complicated setup.
Ok, so what do we have? A Ubuntu development environment (thanks to Windows WSL2 - you’ll need to set it up, it’s just one more googling away, go ahead), mysql and phpmyadmin running in their own containers. Obviously we can’t do anything with that alone. Let’s Go(lang)!