mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Hatchbox Exports Env Vars With asdf as a Devops TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1569 TILs and counting..._
|
||||
_1570 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||
@@ -200,6 +200,7 @@ See some of the other learning resources I work on:
|
||||
- [Check The Syntax Of nginx Files](devops/check-the-syntax-of-nginx-files.md)
|
||||
- [Connect To An RDS PostgreSQL Database](devops/connect-to-an-rds-postgresql-database.md)
|
||||
- [Determine The IP Address Of A Domain](devops/determine-the-ip-address-of-a-domain.md)
|
||||
- [Hatchbox Exports Env Vars With asdf](devops/hatchbox-exports-env-vars-with-asdf.md)
|
||||
- [Path Of The Packets](devops/path-of-the-packets.md)
|
||||
- [Push Non-master Branch To Heroku](devops/push-non-master-branch-to-heroku.md)
|
||||
- [Reload The nginx Configuration](devops/reload-the-nginx-configuration.md)
|
||||
|
||||
44
devops/hatchbox-exports-env-vars-with-asdf.md
Normal file
44
devops/hatchbox-exports-env-vars-with-asdf.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Hatchbox Exports Env Vars With asdf
|
||||
|
||||
When you add env vars through the [Hatchbox](https://hatchbox.io/) UI, they get
|
||||
exported to the environment of the asdf-shimmed processes. This is handled by
|
||||
the [`asdf-vars` plugin](https://github.com/excid3/asdf-vars). That plugin
|
||||
looks for `.asdf-vars` in the current chain of directories.
|
||||
|
||||
I can see there are many `.asdf-vars` files:
|
||||
|
||||
```bash
|
||||
$ find . -name ".asdf-vars" -type f
|
||||
./.asdf-vars
|
||||
./my-app/.asdf-vars
|
||||
./my-app/releases/20250120195106/.asdf-vars
|
||||
./my-app/releases/20250121041054/.asdf-vars
|
||||
```
|
||||
|
||||
And it is the one in my app's directory that contains the env vars that I set
|
||||
in the UI.
|
||||
|
||||
```bash
|
||||
$ cat my-app/.asdf-vars
|
||||
BUNDLE_WITHOUT=development:test
|
||||
DATABASE_URL=postgresql://user_123:123456789012345@10.0.1.1/my_app_db
|
||||
PORT=9000
|
||||
RACK_ENV=production
|
||||
RAILS_ENV=production
|
||||
RAILS_LOG_TO_STDOUT=true
|
||||
RAILS_MASTER_KEY=abc123
|
||||
SECRET_KEY_BASE=abc123efg456
|
||||
```
|
||||
|
||||
When I run a shimmed process like `ruby`, those env vars are loaded into the
|
||||
process's environment.
|
||||
|
||||
```bash
|
||||
$ cd my-app/current
|
||||
$ which ruby
|
||||
/home/deploy/.asdf/shims/ruby
|
||||
$ ruby -e "puts ENV['DATABASE_URL']"
|
||||
postgresql://user_123:123456789012345@10.0.1.1/my_app_db
|
||||
```
|
||||
|
||||
[source](https://www.visualmode.dev/hatchbox-manages-env-vars-with-asdf)
|
||||
Reference in New Issue
Block a user