Skip to content

Latest commit

 

History

History
172 lines (119 loc) · 3.21 KB

File metadata and controls

172 lines (119 loc) · 3.21 KB

Docker Development Environment

This Docker environment provides a consistent development and testing environment for ngfw_pkgtools.

Prerequisites

  • Docker
  • Docker Compose

Quick Start

1. Build the Docker image

make build

Or manually:

docker-compose -f docker-compose.dev.yml build

2. Start the development environment

make up

Or manually:

docker-compose -f docker-compose.dev.yml up -d

3. Access the container shell

make shell

Or manually:

docker-compose -f docker-compose.dev.yml exec ngfw-pkgtools-dev /bin/bash

Running Scripts

Once inside the container shell, you can run any script:

# Example: Run create-branch.py
./create-branch.py --help

# Example: Run with specific parameters
./create-branch.py --branch ngfw-1.0 --product ngfw --simulate

Running Tests

Run unit tests with coverage:

make test

Or manually:

docker-compose -f docker-compose.dev.yml exec ngfw-pkgtools-dev pytest -v --cov=lib --cov-report=term-missing

Run specific tests:

# Run specific test file
docker-compose -f docker-compose.dev.yml exec ngfw-pkgtools-dev pytest tests/test_repoinfo.py -v

# Run specific test
docker-compose -f docker-compose.dev.yml exec ngfw-pkgtools-dev pytest tests/test_repoinfo.py::TestRepositoryInfo -v

See tests/README.md for more details on testing.

Code Quality

Format code

make format

Run linter

make lint

Git Configuration

Gerrit Username

The Gerrit username is automatically configured from your environment:

# Set your Gerrit username (optional, defaults to $USER)
export GERRIT_USER=jsommerville

# Restart container to pick up the change
make down
make up

The username is used in Gerrit SSH URLs: ssh://<username>@gerrit.corp.arista.io:29418/efw/<repo>

SSH Keys for Git Operations

If your scripts need to push to remote repositories, you may need to mount your git credentials:

  1. Uncomment the volume mounts in docker-compose.dev.yml:

    - ~/.gitconfig:/root/.gitconfig:ro
    - ~/.ssh:/root/.ssh:ro
  2. Rebuild and restart:

    make down
    make build
    make up

Installed Dependencies

The Docker image includes:

  • Python 3.7+ (from Debian Buster)
  • Git - Version control
  • GitPython - Python Git library
  • PyYAML - YAML parsing
  • requests - HTTP library
  • pytest - Testing framework
  • pytest-cov - Code coverage
  • ruff - Python linter and formatter

Cleanup

To stop and remove containers:

make down

To remove everything including the image:

make clean

Directory Structure

  • /opt/untangle/ngfw_pkgtools - Working directory inside container
  • Volume mounted to your local directory for live code changes

Troubleshooting

Container won't start

docker-compose -f docker-compose.dev.yml logs

Permission issues

The container runs as root. If you encounter permission issues with generated files, you may need to adjust ownership after running commands.

Python import errors

Make sure you're running commands from the /opt/untangle/ngfw_pkgtools directory inside the container.