# stretch doesn't have the latest golang so we install backports
sudo add-apt-repository "deb http://deb.debian.org/debian stretch-backports main"
sudo apt-get update
sudo apt-get -t stretch-backports install golang
# set the gopath manually for the rest of the setup
export GOPATH=${HOME}/go
Install migrate
# this assumes you have ${GOPATH}/bin in your ${PATH}
go get -u -d github.com/mattes/migrate/cli github.com/lib/pq
go build -tags 'postgres' -o ${GOPATH}/bin/migrate github.com/mattes/migrate/cli
Clone repo and configure the settings
mkdir -p ${GOPATH}/src/git.minhas.io/asara
cd ${GOPATH}/src/git.minhas.io/asara
git clone https://git.minhas.io/asara/sudoscientist-go-backend
# iterate through the environment files in the settings directory and set them appropriately
# make sure the extension is .env (db.env, secrets.env, website.env... etc.)
Configure docker postgres for testing
# make sure your user is in the docker group
sudo usermod -aG docker $(whoami)
# make sure you have some postgres client installed
sudo apt-get install postgres-client
docker pull postgres
docker run --name sudosci-db -e POSTGRES_PASWORD=${DB_ADMIN_PW} -d postgres # please set the db admin pw manually
# Initalize the postgres DB
cd ${GOPATH}/src/git.minhas.io/asara/sudoscientist
for i in settings/*; do source $i; done
export DB_HOST=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" sudosci-db)
psql -d postgres -U postgres -h ${DB_HOST} << EOF
CREATE DATABASE ${DB_NAME};
CREATE USER ${DB_USER} WITH ENCRYPTED PASSWORD '${DB_PW}';
GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} TO ${DB_USER};
ALTER DATABASE ${DB_NAME} OWNER TO ${DB_USER};
EOF
Run the application!
PLEASE NOTE, THERE ARE DEFAULT TEST VALUES FOR A POSTAL SERVER
PLEASE REMOVE THESE IF YOU DONT HAVE A POSTAL BACKEND TO TEST FROM!
cd ${GOPATH}/src/git.minhas.io/asara/sudoscientist-go-backend
for i in settings/*.env; do source $i; done
export DB_HOST=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" sudosci-db)
PSQL_QUERY_STRING="postgres://${DB_USER}:${DB_PW}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=${DB_SSL}"
migrate -path migrations/ -database ${PSQL_QUERY_STRING} up
go get
go run main.go