alloy icon indicating copy to clipboard operation
alloy copied to clipboard

.env working example

Open davidpelayo opened this issue 6 years ago • 1 comments

Hi all.

For newbies in go like me, it would be nice to have and environment file example working, together with the dependencies you need to have on your system to run the project successfully.

If you used a dockerized smtp server image on your machine then document it, or you just pointed to some smtp server (or sendgrid or similar) on the internet when running the project?

Then, the driverName or connection string for establishing the SQL connection, and so on.

Do you think it would be possible?

davidpelayo avatar Nov 30 '17 15:11 davidpelayo

Updating my raised issue.

I've found the SQL string format you need to provide, after googling a bit, here, looking at this example:

func main() {  
  psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
    "password=%s dbname=%s sslmode=disable",
    host, port, user, password, dbname)
}

An example of a .env file to load before alloy dev would be:

export PORT=1212
export ENVIRONMENT=development
export HOST=localhost
export DATABASE_URL="host=127.0.0.1 port=5432 user=<user> password=<password> dbname=<db_name> sslmode=disable"
export DATABASE_URL="host=127.0.0.1 port=5432 user=<user> password=<password> dbname=<db_name> sslmode=disable"
export MIGRATIONS_DIR=app/migrations
export CSRF_KEY=XXX
export HASH_KEY=XXX
export BLOCK_KEY=XXX
export SMTP_HOST=<smtp_host>
export SMTP_PORT=<smtp_port>
export SMTP_USERNAME=<your_smtp_username>
export SMTP_PASSWORD=<your_smtp_password>
export MAILER_FROM=<some_email>
export MAILER_HOST=http://localhost:1212
export ASSET_URL=http://localhost:1212

And do not forget to have localhost pointing to 127.0.0.1 in your /etc/hosts.

davidpelayo avatar Nov 30 '17 16:11 davidpelayo