README
Docker Support for Inline::Python3
This directory contains Docker configurations for building, testing, and deploying Inline::Python3.
Quick Start
# Build and start development environment
make dev
# Run tests
make test
# Start Jupyter notebook
make jupyterAvailable Images
1. Development Image (inline-python3:dev)
Full development environment with:
Raku and Python 3.11
All development tools (vim, gdb, etc.)
Python scientific stack (numpy, pandas, scikit-learn)
Jupyter notebook support
Test frameworks
2. Production Image (inline-python3:prod)
Minimal runtime environment with:
Raku and Python 3.11
Only essential Python packages
Non-root user for security
Read-only filesystem capability
3. Test Image (inline-python3:test)
Testing environment with:
All test dependencies
Test runners configured
Coverage tools
4. Multi-Python Images
inline-python3:py38- Python 3.8inline-python3:py39- Python 3.9inline-python3:py310- Python 3.10
Docker Compose Services
Development Services
# Interactive development shell
docker-compose run --rm dev
# Run specific command
docker-compose run --rm dev raku examples/data-science.rakuTesting Services
# Run all tests
docker-compose run --rm test
# Test with specific Python version
docker-compose run --rm python38
docker-compose run --rm python39
docker-compose run --rm python310Jupyter Notebook
# Start Jupyter (accessible at http://localhost:8888)
docker-compose up jupyterDocumentation
# Generate API documentation
docker-compose run --rm docsBenchmarking
# Run performance benchmarks
docker-compose run --rm benchmarkMakefile Commands
The Makefile provides convenient shortcuts:
make help # Show all commands
make build # Build all images
make dev # Start development container
make test # Run test suite
make prod # Build production image
make jupyter # Start Jupyter notebook
make docs # Generate documentation
make benchmark # Run benchmarks
make multi-python # Test with all Python versions
make clean # Remove all containers and imagesBuilding Images
Development Build
docker build --target development -t inline-python3:dev .Production Build
docker build --target production -t inline-python3:prod .Custom Python Version
docker build -f Dockerfile.python38 -t inline-python3:py38 .Volume Mounts
The development container mounts several volumes:
.:/workspace- Project filesraku-cache:/root/.raku- Raku module cachepython-cache:/root/.cache/pip- Python package cache
Environment Variables
Key environment variables set in containers:
PERL6LIB=/workspace/lib- Raku library pathLD_LIBRARY_PATH=/workspace/resources/libraries- C library pathPYTHONUNBUFFERED=1- Unbuffered Python output
Security Considerations
The production image includes security features:
Non-root user (
appuser)Read-only root filesystem capability
No new privileges flag
Dropped Linux capabilities
Troubleshooting
C Library Issues
If the C library fails to build:
# Rebuild just the library
docker-compose run --rm dev bash -c "cd src && make clean && make"Python Version Conflicts
Check Python version in container:
docker-compose run --rm dev python3 --versionPermission Issues
If you encounter permission issues with mounted volumes:
# Run as root user
docker-compose run --rm --user root devCI/CD Integration
GitHub Actions Example
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests in Docker
run: |
docker build --target test -t inline-python3:test .
docker run --rm inline-python3:testGitLab CI Example
test:
image: docker:latest
services:
- docker:dind
script:
- docker build --target test -t inline-python3:test .
- docker run --rm inline-python3:testDeployment
Using Production Image
FROM inline-python3:prod
# Copy your application
COPY my-app.raku /app/
# Run your application
CMD ["raku", "/app/my-app.raku"]Docker Swarm
version: '3.8'
services:
app:
image: inline-python3:prod
deploy:
replicas: 3
resources:
limits:
cpus: '0.5'
memory: 512MKubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: inline-python3-app
spec:
replicas: 3
template:
spec:
containers:
- name: app
image: inline-python3:prod
resources:
limits:
memory: "512Mi"
cpu: "500m"Best Practices
Use specific targets: Build only what you need (dev/prod/test)
Cache dependencies: Use volume mounts for package caches
Multi-stage builds: Keep production images small
Security scanning: Run
make security-scanregularlyVersion pinning: Pin Python and Raku versions for reproducibility