Nixius
/
template
Template
2
1
Fork 1
template/README.md

126 lines
3.3 KiB
Markdown

# Template Project
This is a template project that follows a standardized structure for Docker-based applications.
## Project Structure
```
./
├── .woodpecker.yml # CI configuration
├── build-test-run.sh # Convenience script for local development
├── docker/
│ └── template/ # Main application container
│ ├── Dockerfile # Base Dockerfile
│ ├── Dockerfile.production # Production-specific Dockerfile
│ └── src/ # Application source code
├── tests/ # Test scripts
├── temp/ # Local testing scratch space
├── docker-compose.dev.yml # Docker Compose for local development
├── docker-compose.production.yml
├── docker-compose.staging.yml
├── docker-compose.test.yml
├── stack.staging.yml
└── stack.production.yml
```
## Local Development
### Quick Start
The easiest way to get started with local development is to use the `build-test-run.sh` script:
```bash
./build-test-run.sh
```
This script will:
1. Build the Docker images using docker-compose.dev.yml
2. Run tests if available
3. Start all services in the background
4. Display the URL to access the application
### Development Compose File
The `docker-compose.dev.yml` file is designed for local development. It includes:
- Volume mounts for code changes without rebuilding
- Debug environment variables
- Health checks
- Local ports for easy access
To use it directly:
```bash
# Build and start in one command
docker compose -f docker-compose.dev.yml up --build
# Run in the background
docker compose -f docker-compose.dev.yml up -d
# View logs
docker compose -f docker-compose.dev.yml logs -f
# Stop services
docker compose -f docker-compose.dev.yml down
```
### Using the `temp` Directory
The `./temp/` directory serves as a scratch space for local testing and development. It's designed to store temporary files that shouldn't be committed to version control, such as:
- Test output logs (e.g., `test_output.log`)
- Temporary build artifacts
- Local configuration overrides
- Mock data for testing
- Debug logs and crash reports
#### Example Usage
1. Running tests with output:
```bash
# Test output will be written to ./temp/test_output.log
./tests/run_tests.sh > ./temp/test_output.log
```
2. Local configuration:
```bash
# Create a local config override
cp config.yml ./temp/local_config.yml
# Edit local_config.yml for testing
```
3. Debug logs:
```bash
# Application debug logs
docker-compose -f docker-compose.test.yml up > ./temp/debug.log
```
### Important Notes
- The `./temp/` directory is git-ignored
- Files in this directory are temporary and can be safely deleted
- Use this directory for any files that shouldn't be committed to version control
- The directory is mounted in test containers for easy access to test outputs
## Development Workflow
1. Start local development:
```bash
./build-test-run.sh
# or
docker compose -f docker-compose.dev.yml up --build
```
2. Run tests:
```bash
./tests/run_tests.sh
```
3. Check test outputs in `./temp/` directory
4. Clean up temporary files:
```bash
rm -rf ./temp/*
```
## CI/CD
The project uses Woodpecker CI for continuous integration. The `temp` directory is not included in CI builds to ensure clean, reproducible builds.