Tamiat CMS backend
- Golang 1.6 or higher
You may use these steps to install go on your Linux machine or use the previous link to get the latest versions of go.
- Open your terminal and make sure you are at home path
- Download the go package.
wget https://go.dev/dl/go1.17.7.linux-amd64.tar.gz - Extract go files
sudo tar -C /usr/local -xzf go1.17.7.linux-amd64.tar.gz - Add the following line to /home/<your_username/.profile file by using your preferred text editor.
export PATH=$PATH:/usr/local/go/bin - To apply the changes made to .proile file run:
source $HOME/.profile - Make sure you installed go by running:
go versionYou will get output message like this:go version go1.17.7 linux/amd64
- Postgresql Follow the instructions here: (https://www.postgresql.org/download/)
- Clone the repository at any path
git clone https://github.com/tamiat/backend.git cd backend- Create postgresql database and set password for postgres user
sudo -i -u postgrespsqlCREATE DATABASE <database_name>;ALTER USER postgres WITH PASSWORD '<new_password>';
- (Optional) you can use the following instructions to create the database with a different user:
sudo -u postgres psql postgresCREATE ROLE <username> LOGIN PASSWORD 'new_password';CREATE DATABASE <database_name> WITH OWNER = <username>SHOW portthis gives you the DBPORT - type
exittwice to return to the terminal. - At backend directory rename .env.example file to .env
mv .env.example .envThis file contains all necessarily environment variables.
| Environment Variable | Explanation |
|---|---|
| HOST | ex: localhost |
| DBNAME | database name |
| DBPASS | database password |
| DBPORT | database port, set to 5432 |
| PORT | which port number to use for endpoints, ex: 8080 |
| DBUSER | database user, ex: postgres |
| JWT_SECRET | string to set secret of jwt |
| EMAIL_SENDER | the email that will send confirmation emails to users. It should be activated in sendgrid profile |
| TEMPLATE_ID | which template id sendgrid uses as a format to send emails |
| SENDGRID_API_KEY | api key associated with the sender account |
- Set environment variables using your preferred text editor
- Back to backend directory, run:
go get github.com/gobuffalo/pop/... - Edit ~/.profile and add this line into it.
export PATH=$PATH:~/go/bin - Run the following command to apply changes to .profile
source ~/.profile - Run the following command
which sodaIt should give output like this:/home/<user_name>/go/bin/soda - Now run the following to create all database tables
soda migrate up
In the project root directory run
go run main.go