Skip to content

Greenlight app from Alex Edward's "Let's Go Further"

Notifications You must be signed in to change notification settings

WannaFight/greenlight

Repository files navigation

Greenlight

Setup

Copy env and populate with data:

cp .env.template .env

For database DSN use somethong like this:

DB_DSN=postgres://username:password@localhost/databse?sslmode=disable

Install additional packages:

go install github.com/cosmtrek/air@latest  # for live reload
brew install golang-migrate
brew install pre-commit  # style check
pre-commit install

Run containers:

docker compose up -d
docker compose ps  # everything has to be up and running

Connect to database using docker compose exec db psql -U postgres. Following commands might raise an exception that something is already exists – it's ok:

CREATE DATABASE greenlight;
CREATE ROLE greenlight WITH LOGIN PASSWORD 'password';
CREATE EXTENSION IF NOT EXISTS citext;

Apply migrations. Value of database option is DB_DSN from environment:

migrate -path=./migrations -database="postgres://greenlight:password@localhost/greenlight?sslmode=disable" up

Todos

[ ] add init sql (role creation etc) to docker compose
[ ] move golang with air to docker
[ ] apply migration inside docker

About

Greenlight app from Alex Edward's "Let's Go Further"

Topics

Resources

Stars

Watchers

Forks