Environment Variable Configuration
wukong-deploy supports managing sensitive information and environment-specific settings through environment variables.
Basic Usage
Use environment variables in the configuration file:
// config.mjs
export default {
servers: {
prod: {
host: '127.34.5.53',
username: 'root',
passwordEnv: 'PROD_SERVER_PASSWORD', // .env.wukong PROD_SERVER_PASSWORD="yourpassword"
},
},
};
Environment Variable Files
wukong-deploy loads environment variables from .env.wukong (generated by wukong-deploy init):
# .env.wukong
PROD_SERVER_PASSWORD=your-secure-password
The following files are also supported, in order of precedence (see below):
# .env.dev — target-specific overrides (e.g. wukong-deploy deploy dev)
# .env.wukong — default file generated by `wukong-deploy init`
# .env — legacy file (still read as a fallback)
Configuration Priority
The loading priority of environment variables (from highest to lowest) is:
- Command-line arguments
- Environment variables (shell exports)
.env.{target}(e.g..env.dev,.env.prod) — target-specific overrides.env.wukong— default file generated bywukong-deploy init.env— legacy fallback (only used if the above are absent)
Compatibility
Prior to v1.2.42,
.envwas used. The current version still reads.envas a fallback, but.env.wukong(generated bywukong-deploy init) takes precedence. You can also provide a target-specific.env.{target}(e.g..env.dev) to override variables for a specific server.
Security Recommendations
- Do not commit
.env,.env.wukong, or.env.{target}files to version control - Use
.env.example(or.env.wukong.example) as a template - Set appropriate file permissions
- Regularly update keys and passwords