Things we're going to do in this tutorial are:
- Create a go-app
- Dockerize the app
- Deploy the app on k3s
To start the mysql server locally run:
docker run -d -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=root mysql
This will open mysql in your terminal, and will also create a database named todolist.
docker exec -it mysql mysql -uroot -proot
After creating a database, we need to create a table
CREATE DATABASE todolist;
CREATE TABLE todos(id int, todo varchar(255));
To build your own image run:
docker build -t go-simple .
To run the image & to connect it to database container run:
docker run -d --network host --name go-simple go-simple
To test the app working run or visit http://localhost:5000/home in your browser.
curl http://localhost:5000/home