Skip to content

Commit b7f4f2d

Browse files
committed
Fix how root .env file is loaded
The previous method wasn't working for manually loading the root .env or when using devbox services.
1 parent fe35337 commit b7f4f2d

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
77
USER ${DEVBOX_USER}:${DEVBOX_USER}
88
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
99
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
10+
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} .env.example .env
1011

1112

1213
RUN devbox run -- echo "Installed Packages." && nix-store --gc && nix-store --optimise

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dockerfile": "./Dockerfile",
55
"context": ".."
66
},
7-
"postCreateCommand": "devbox run setup",
7+
"postCreateCommand": "bin/ensure-root-env-file && devbox run setup",
88
"customizations": {
99
"vscode": {
1010
"settings": {},

.rootenvrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# source this file to manually load environment variables from .env file
2+
# (not needed if you use devbox, process-compose, direnv, etc.)
3+
set -a
4+
[ -f .env ] && source .env
5+
set +a

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ firebase emulators:start --project demo-bdt-dev --only auth,firestore,storage
149149

150150
```bash
151151
# then start up services one by one in new shells, e.g.:
152-
bin/load-root-env
152+
source .rootenvrc
153153
cd builder-api
154154
quarkus dev
155155
```

bin/load-root-env

Lines changed: 0 additions & 7 deletions
This file was deleted.

devbox.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
"google-cloud-sdk@latest",
99
"nodejs@22"
1010
],
11+
"env_from": ".env",
1112
"shell": {
1213
"init_hook": [
13-
"bin/ensure-root-env-file || echo 'error ensuring root .env file'",
14-
"bin/load-root-env || echo 'error loading root .env'",
1514
"command -v bin/devbox-init-hook >/dev/null && bin/devbox-init-hook || true",
1615
"echo 'Welcome to devbox!'"
1716
],

0 commit comments

Comments
 (0)