Skip to content

Commit 48ad9e8

Browse files
committed
update README
1 parent 996dca4 commit 48ad9e8

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

README.md

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,23 @@ DATABASE_URL postgres://yourusername@localhost/my_database
226226
 
227227

228228
</details>
229-
<details><summary>Syncing</summary><br>
230229

231-
You need to keep `.env` files in sync between machines, environments, or team members? Use [dotenvx](https://github.com/dotenvx/dotenvx) to encrypt your `.env` files and safely include them in source control. This still subscribes to the twelve-factor app rules by generating a decryption key separate from code.
230+
<details><summary>Encryption</summary><br>
231+
232+
Use [dotenvx](https://github.com/dotenvx/dotenvx).
233+
234+
Add encryption to your `.env` files with a single command. Pass the `--encrypt` flag.
235+
236+
```
237+
$ dotenvx set HELLO Production --encrypt -f .env.production
238+
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
239+
240+
$ DOTENV_PRIVATE_KEY_PRODUCTION="<.env.production private key>" dotenvx run -- node index.js
241+
[dotenvx] injecting env (2) from .env.production
242+
Hello Production
243+
```
244+
245+
[learn more](https://github.com/dotenvx/dotenvx?tab=readme-ov-file#encryption)
232246

233247
&nbsp;
234248

@@ -264,32 +278,46 @@ Hello local
264278
&nbsp;
265279

266280
</details>
267-
<details><summary>Deploying</summary><br>
268-
269-
You need to deploy your secrets in a cloud-agnostic manner? Use [dotenvx](https://github.com/dotenvx/dotenvx) to generate a private decryption key that is set on your production server.
281+
<details><summary>Production</summary><br>
270282

271-
&nbsp;
283+
Use [dotenvx](https://github.com/dotenvx/dotenvx)
272284

273-
</details>
285+
Create a `.env.production` file.
274286

275-
&nbsp;
287+
```sh
288+
$ echo "HELLO=production" > .env.production
289+
```
276290

277-
## Deploying
291+
Encrypt it.
278292

279-
Use [dotenvx](https://github.com/dotenvx/dotenvx).
293+
```sh
294+
$ dotenvx encrypt -f .env.production
295+
```
280296

281-
Add encryption to your `.env` files with a single command. Pass the `--encrypt` flag.
297+
Set `DOTENV_PRIVATE_KEY_PRODUCTION` (found in `.env.keys`) on your server.
282298

283299
```
284-
$ dotenvx set HELLO Production --encrypt -f .env.production
285-
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js
300+
$ heroku config:set DOTENV_PRIVATE_KEY_PRODUCTION=value
301+
```
302+
303+
Commit your `.env.production` file to code and deploy.
286304

287-
$ DOTENV_PRIVATE_KEY_PRODUCTION="<.env.production private key>" dotenvx run -- node index.js
288-
[dotenvx] injecting env (2) from .env.production
289-
Hello Production
305+
```
306+
$ git add .env.production
307+
$ git commit -m "encrypted .env.production"
308+
$ git push heroku main
290309
```
291310

292-
[learn more](https://github.com/dotenvx/dotenvx?tab=readme-ov-file#encryption)
311+
&nbsp;
312+
313+
</details>
314+
<details><summary>Syncing</summary><br>
315+
316+
You need to keep `.env` files in sync between machines, environments, or team members? Use [dotenvx](https://github.com/dotenvx/dotenvx) to encrypt your `.env` files and safely include them in source control. This still subscribes to the twelve-factor app rules by generating a decryption key separate from code.
317+
318+
&nbsp;
319+
320+
</details>
293321

294322
&nbsp;
295323

0 commit comments

Comments
 (0)