Deploy Component
The deploy component provides standardized deployment configuration for your GitLab CI / CD pipelines.
Usageโ
Include the deploy component in your .gitlab - ci.yml
:
include:
- component: [COMPONENT_REGISTRY] / [email protected]
inputs:
environment: 'production'
deploy_command: 'npm run deploy'
```text
## Configuration
### Required Inputs
| Input | Description | Default |
| ---------------- | ------------------------- | ------- |
| `environment`| Target environment | None |
|`deploy_command`| Command to run deployment | None |
### Optional Inputs
| Input | Description | Default |
| -------------------- | ------------------------------- | --------- |
|`node_version`| Node.js version to use |`18`|
|`deploy_strategy`| Deployment strategy |`rolling`|
|`timeout`| Deployment timeout in seconds |`600`|
|`pre_deploy_script`| Script to run before deployment | None |
|`post_deploy_script`| Script to run after deployment | None |
|`healthcheck_url`| URL to check after deployment | None |
|`rollback_command`| Command to run for rollback | None |
## Examples
### Basic Usage
```yaml
deploy:
extends: .deploy
variables:
ENVIRONMENT: 'production'
DEPLOY_COMMAND: 'npm run deploy'
```text
### Staged Deployment
```yaml
deploy - staging:
extends: .deploy
variables:
ENVIRONMENT: 'staging'
DEPLOY_COMMAND: 'npm run deploy:staging'
only:
- develop
deploy - production:
extends: .deploy
variables:
ENVIRONMENT: 'production'
DEPLOY_COMMAND: 'npm run deploy:prod'
only:
- main
```text
### Advanced Configuration
```yaml
deploy:
extends: .deploy
variables:
ENVIRONMENT: 'production'
DEPLOY_COMMAND: 'npm run deploy'
DEPLOY_STRATEGY: 'blue - green'
HEALTHCHECK_URL: 'https://api.example.com / health'
ROLLBACK_COMMAND: 'npm run rollback'
PRE_DEPLOY_SCRIPT: 'npm run db:migrate'
POST_DEPLOY_SCRIPT: 'npm run cache:clear'
```text
## Deployment Strategies
### Rolling Update
Default strategy with zero - downtime deployment:
```yaml
variables:
DEPLOY_STRATEGY: 'rolling'
```text
### Blue - Green Deployment
Switch between two identical environments:
```yaml
variables:
DEPLOY_STRATEGY: 'blue - green'
```text
### Canary Deployment
Gradual rollout to production:
```yaml
variables:
DEPLOY_STRATEGY: 'canary'
CANARY_PERCENTAGE: '10'
```text
## Environment Variables
### Available Variables
| Variable | Description |
| --------------------- | ---------------- |
| `CI_ENVIRONMENT_NAME`| Environment name |
|`CI_ENVIRONMENT_URL`| Environment URL |
|`CI_DEPLOY_USER`| Deployment user |
|`DEPLOY_TOKEN`| Deployment token |
### Custom Variables
You can set custom environment variables:
```yaml
variables:
MY_DEPLOY_VAR: 'value'
```text
## Best Practices
1. Environment Management
- Use environment - specific configs
- Implement proper access control
- Monitor deployment status
2. Deployment Safety
- Always use healthchecks
- Implement rollback procedures
- Test deployments in staging
3. Monitoring
- Track deployment times
- Monitor error rates
- Set up alerts
## Troubleshooting
### Common Issues
1. Deployment Failures
- Check deployment logs
- Verify environment access
- Review error messages
2. Rollback Problems
- Test rollback procedures
- Keep deployment history
- Document recovery steps
3. Performance Issues
- Monitor resource usage
- Check network connectivity
- Optimize deployment steps
## Support
Need help? Check our [Support Guide](.. / guide / support.md) or [create an issue](https://gitlab.bluefly.io / bluefly / internal - projects / llm / bfcicomponents/ - /issues).