Categorygithub.com/wlachs/blog
module
0.2.0
Repository: https://github.com/wlachs/blog.git
Documentation: pkg.go.dev

# README

wlachs' blog

CircleCI

A lightweight blog engine implemented in Go.


Setup

Follow the guide to deploy your very own blog engine!

Prerequisites

For a successful deployment, you need Docker. You can use Docker Desktop or Colima if you prefer a command-line-only solution.

Configuration

To customize the blog engine, you must edit the configuration files. These contain, among other essential settings, the primary user's name. The configuration files are at build/env. Do NOT upload these files to your version control.

I highly recommend you change the highlighted properties.

core.env:

KeyDefaultDescription
JWT_SIGNING_KEY-This should be a strong password for signing authentication tokens.
DEFAULT_USER-Name of the primary user. Change this to your name.
DEFAULT_PASSWORD-Primary user's password.
GIN_MODERELEASELeave in on "RELEASE" unless you know what you're doing.

shared.env:

KeyDefaultDescription
MYSQL_USERblog_adminDatabase username. There is no need to change if you use the preconfigured MySQL docker container.
MYSQL_PASSWORDpasswordDatabase password. There is no need to change if you use the preconfigured MySQL docker container.
MYSQL_DATABASEblogDatabase schema. There is no need to change if you use the preconfigured MySQL docker container.
MYSQL_HOSTdbDatabase hostname. Change this if you use your database instead of the one in the docker container.
MYSQL_PORT3306Database port. Change this if you use your database instead of the one in the docker container.

db.env:

KeyDefaultDescription
MYSQL_ROOT_PASSWORD-Database root password. There is no need to provide it if you use your database.

Deployment

After successfully customizing your configuration files, there is only one more step: deployment.

docker compose build
docker compose up

For contribution and development

If you'd like to run the blog engine in developer mode to test it or contribute, there are a few differences.

First, you need a database. You can deploy a MySQL database in a Docker container like in a "real" release. Just make sure you remember the username and the password.

Then, you must set your machine's environment variables as in the configs above. I recommend using a tool such as direnv. In this case, you can set the variables the following way:

export JWT_SIGNING_KEY=SuperSecret
export MYSQL_ROOT_PASSWORD=root
export MYSQL_USER=blog_admin
export MYSQL_PASSWORD=password
export MYSQL_DATABASE=blog
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export PORT=8080
export DEFAULT_USER=TestUser
export DEFAULT_PASSWORD=Test1234

Of course, you should change the values to match the ones you have used for the database deployment.

Last but not least, you have to install Go. If you are using macOS and have Homebrew installed, you can install Go by running the following command:

brew install go

Now that everything is ready, you can navigate to cmd/blog and run the following command:

go run .

Happy coding!

Testing

To ensure the stability of the blog engine and that new features don't accidentally break existing ones, I've decided to implement unit tests. You can follow the current state of test coverage on various software components in the table below.

ComponentCoverage (%)State
Controllers
AuthController100%:white_check_mark:
PostController100%:white_check_mark:
UserController100%:white_check_mark:
Services
PostService100%:white_check_mark:
UserService100%:white_check_mark:
Repositories
PostRepository100%:white_check_mark:
UserRepository100%:white_check_mark:
Utils
AuthUtils100%:white_check_mark:
TokenUtils100%:white_check_mark:

# Packages

No description provided by the author
No description provided by the author