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 | sh
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["dotenvx", "run", "--", "node", "index.js"]
For custom builds and installation options, see dotenvx install.
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 to your production private key and DOTENV_FILE to .env.production in Render's environment variable manager, then redeploy. Your app injects env from the encrypted .env.production file.