/ Search - type / Modes - type M Star on GitHub - 5.7k

Docs

Render

Use dotenvx with Render.

Find code examples for this guide on GitHub.

Deploying to Render takes more steps than we document here. Follow their Docker guide (Render recognizes your Dockerfile automatically). This guide shows the dotenvx pieces in a Docker context.

Dockerfile

# .dockerignore
.env.keys
# Dockerfile
FROM node:20
WORKDIR /app

RUN curl -sfS https://dotenvx.sh/install.sh | sh

COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000

CMD ["dotenvx", "run", "--", "node", "index.js"]

If you prefer, install from GitHub Releases or view the install.sh file before executing.

Encrypt production

# .env.production
HELLO="production"
$ dotenvx encrypt -f .env.production

Commit .env.production. Do not commit .env.keys.

Set decryption key

Set DOTENV_PRIVATE_KEY_PRODUCTION in Render's environment variable manager, then redeploy. Your app injects env from the encrypted .env.production file.