Project Structure of docker-to-iac Module
The project follows standard npm module organization with a well-defined structure to handle both Docker run commands and Docker Compose files, supporting multiple output formats and comprehensive testing.
Directory Structure
docker-to-iac/
|-- src/ # Source code
| |-- index.ts # Main entry point
| |-- config/ # Provider-specific configurations
| | |-- connection-properties.ts
| | |-- digitalocean/
| | | |-- database-types.ts
| | |-- render/
| | |-- service-types.ts
| |-- parsers/ # IaC parsers for different cloud providers
| | |-- aws-cloudformation.ts
| | |-- base-parser.ts
| | |-- digitalocean.ts
| | |-- render.ts
| |-- sources/ # Input source handlers
| | |-- base.ts
| | |-- factory.ts
| | |-- compose/ # Docker Compose handling
| | | |-- index.ts
| | | |-- validate.ts
| | |-- run/ # Docker run command handling
| | |-- index.ts
| |-- types/ # TypeScript type definitions
| | |-- container-config.ts
| | |-- environment-config.ts
| | |-- service-connections.ts
| |-- utils/ # Helper utilities
| |-- constructImageString.ts
| |-- detectDatabaseEnvVars.ts
| |-- digitalOceanParserServiceName.ts
| |-- getDigitalOceanDatabaseType.ts
| |-- getImageUrl.ts
| |-- parseCommand.ts
| |-- parseDockerImage.ts
| |-- parseEnvFile.ts
| |-- processEnvironmentVariablesGeneration.ts
| |-- resolveEnvironmentValue.ts
| |-- (... and many more)
|-- test/ # Test files
| |-- e2e/ # End-to-end tests
| | |-- assertions/ # Test assertions
| | | |-- digitalocean.ts
| | | |-- do-port-assertions.ts
| | | |-- port-assertions.ts
| | | |-- render.ts
| | |-- docker-compose-files/ # Test Docker Compose files
| | |-- docker-run-files/ # Test Docker run commands
| | |-- output/ # Test output directory
| | |-- utils/ # Test utilities
| | |-- index.ts # Main E2E test executor
| | |-- test1.ts # Environment variables and volume mapping tests
| | |-- test2.ts # Port mapping tests
| | |-- test3.ts # Environment variable substitution tests
| | |-- test4.ts # Schema validation tests
| |-- unit/ # Unit tests
| | |-- config/ # Configuration tests
| | |-- parsers/ # Parser tests
| | |-- sources/ # Source handler tests
| | |-- utils/ # Utility function tests
| |-- test.ts # Main test entry point
|-- eslint.config.mjs # ESLint configuration
|-- tsconfig.json # TypeScript configuration
|-- vitest.config.ts # Vitest configuration
|-- package.json # Package configuration
|-- README.md # Project documentation
Directory Purposes
Core Directories
src/
- Source code for the moduletest/
- Test files organized by test type (unit and end-to-end)dist/
- Compiled output (generated during build)
Source Code Organization
Config (src/config/
)
Contains provider-specific configurations:
connection-properties.ts
- Cross-provider connection property mappingsdigitalocean/
- DigitalOcean App Platform specific configurationsdatabase-types.ts
- Database type mappings for DigitalOcean
render/
- Render.com specific configurationsservice-types.ts
- Service type mappings for Render deployments
Parsers (src/parsers/
)
Contains IaC-specific parsers for different cloud providers:
base-parser.ts
- Base parser class that defines common functionalityaws-cloudformation.ts
- AWS CloudFormation parserdigitalocean.ts
- DigitalOcean App Platform parserrender.ts
- Render Blueprint parser- ... additional parsers for other providers
Source Handlers (src/sources/
)
Handles different input types:
base.ts
- Base source handler interfacefactory.ts
- Factory for creating appropriate source handlerscompose/
- Docker Compose file processingindex.ts
- Main Compose parservalidate.ts
- Compose file validation
run/
- Docker run command processingindex.ts
- Docker run command parser
Types (src/types/
)
TypeScript type definitions:
container-config.ts
- Container and service configuration typesenvironment-config.ts
- Environment variable configuration typesservice-connections.ts
- Service connection configuration types
Utilities (src/utils/
)
Helper functions for parsing and processing:
constructImageString.ts
- Docker image string constructiondetectDatabaseEnvVars.ts
- Database environment variable detectiondigitalOceanParserServiceName.ts
- Name formatting for DigitalOceangetDigitalOceanDatabaseType.ts
- Database type detection for DigitalOceanparseDockerImage.ts
- Docker image parsingparseEnvFile.ts
- Environment file parsingresolveEnvironmentValue.ts
- Environment variable resolution- And many more utility functions for specific operations
Test Organization
End-to-End Tests (test/e2e/
)
Integration tests that validate the complete workflow:
assertions/
- Validation functions for test outputdocker-compose-files/
- Test Docker Compose filesdocker-run-files/
- Test Docker run commandsoutput/
- Generated test outputsutils/
- Test helper utilitiestest1.ts
throughtest4.ts
- Specific test scenarios:- Environment variables and volume mapping
- Port mappings
- Environment variable substitution
- Schema validation
Unit Tests (test/unit/
)
Tests for individual components:
config/
- Tests for configuration modulesparsers/
- Tests for IaC parserssources/
- Tests for source handlersutils/
- Tests for utility functions
Adding New Parser
Please check our Adding a New Parser documentation for detailed instructions on how to add a new parser to the project. This includes creating a new parser file, implementing the parsing logic, and ensuring compatibility with existing configurations.
Adding New Tests
Please refer to the Testing documentation for guidelines on adding new tests, including unit and end-to-end tests.