Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

#### Express Application Support
- **Express Project Detection**: Added automatic detection of Express.js applications
- Detects Express apps by checking for `express` dependency in `package.json`
- Requires absence of `services.json` and `manifest.json` (distinguishes from Foxx services)
- Project type: `express`

- **Express Dockerfile Template**: Created `Dockerfile.express.template` for Express applications
- Uses Node.js 22 base image (`arangodb/node22base:latest`)
- Runs Express apps directly with `node {ENTRYPOINT}` instead of `node-foxx`
- No `services.json` or `manifest.json` required
- Entrypoint auto-detected from `package.json` `main` field or `start` script
- Defaults to `index.js` if not found

- **Express Preparation Script**: Added `scripts/prepareproject-express.sh`
- Similar to Node.js preparation but without `node-foxx` checks
- Installs only missing/incompatible dependencies
- Uses base `node_modules` from base image via NODE_PATH

- **Environment Variables from `.env.example`**: Added support for reading environment variables
- Automatically reads `.env.example` file if present in project root
- Parses `KEY=VALUE` format with support for quoted values
- Injects environment variables as `ENV` directives in Dockerfile
- Supports comments (lines starting with `#`) and empty lines
- Handles values with spaces or special characters (auto-quotes for Docker)
- Works for all project types (Python, Foxx, Express)

#### Node.js/Foxx Service Support
- **Node.js Base Image**: Added `Dockerfile.node22base` for Node.js 22 base image with pre-installed packages
- Installs Node.js 22 from NodeSource
Expand Down Expand Up @@ -36,9 +62,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **Project Type Detection**: Extended `detect_project_type()` to support:
- `python`: Projects with `pyproject.toml`
- `express`: Express.js applications with `express` dependency, no `services.json` or `manifest.json`
- `foxx`: Multi-service projects with `package.json` and `services.json` (both required)
- `foxx-service`: Single service directory with `package.json` only (auto-generates `services.json`)
- Execution stops with error if `services.json` is missing for Node.js projects

- **Service Structure Generation**: Simplified structure for single service directories
- Copies service directory directly to `/project/{service-name}/` (no wrapper folder)
Expand Down Expand Up @@ -66,16 +92,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **Main Application Logic**: Extended `src/main.rs` to support Node.js/Foxx projects
- **Main Application Logic**: Extended `src/main.rs` to support Node.js/Foxx and Express projects
- Added Express project type detection and handling
- Added entrypoint auto-detection for Express apps from `package.json`
- Added environment variable reading from `.env.example` for all project types
- Added Dockerfile modification functions for Express apps (`modify_dockerfile_express`)
- Added Express preparation script to embedded scripts list
- Added project type detection requiring both `package.json` and `services.json` for `foxx` type
- Error handling: execution stops if `services.json` is missing for Node.js projects
- Simplified file copying: projects are copied as-is (no wrapper structure generation)
- Base image default handling: Introduced compile-time constants (`DEFAULT_PYTHON_BASE_IMAGE`, `DEFAULT_NODEJS_BASE_IMAGE`)
- Explicit user intent tracking: Changed `base_image` to `Option<String>` to detect explicit user choices
- Smart defaults: Only sets project-type-specific defaults when user hasn't explicitly set base image
- Modified Dockerfile generation to use Node.js template for Foxx projects
- Updated Helm chart generation to support Node.js/Foxx projects
- Added `prepareproject-nodejs.sh` and `check-base-dependencies.js` to embedded scripts list
- Modified Dockerfile generation to use appropriate template based on project type
- Updated Helm chart generation to support all project types (Python, Express, Foxx)
- Added `prepareproject-express.sh` to embedded scripts list
- No entrypoint required for Foxx services (uses `node-foxx` from base image)

- **Entrypoint Script**: Enhanced `baseimages/scripts/entrypoint.sh` to support Node.js/Foxx services
Expand All @@ -96,7 +126,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Technical Details

For detailed information about base image structure, service architecture, and module resolution, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
For detailed information about:
- **Node.js/Foxx Services**: Base image structure, service architecture, and module resolution - see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
- **Express Applications**: Express app architecture, detection, and deployment - see [docs/ARCHITECTURE_EXPRESS.md](docs/ARCHITECTURE_EXPRESS.md)
- **Service Comparison**: Differences between Node-Foxx and Express+Arangojs services - see [docs/SERVICE_COMPARISON.md](docs/SERVICE_COMPARISON.md)

## [0.9.2] - Previous Release

Expand All @@ -113,14 +146,16 @@ For detailed information about base image structure, service architecture, and m
## Version History

- **0.9.2**: Initial release with Python support
- **Unreleased**: Added Node.js/Foxx service support
- **Unreleased**: Added Node.js/Foxx service support and Express application support

---

## Notes

- All changes maintain backward compatibility with existing Python projects
- Node.js support is additive and does not affect Python service functionality
- Node.js support (both Foxx and Express) is additive and does not affect Python service functionality
- Express applications are detected automatically and require no special configuration files
- Environment variables from `.env.example` are automatically injected into Docker images
- Base images must be built separately using `baseimages/build.sh`
- Windows users should use WSL or Linux environment for building base images

23 changes: 23 additions & 0 deletions Dockerfile.express.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM {BASE_IMAGE}

USER root

COPY ./scripts /scripts
COPY {PROJECT_DIR} /project/{PROJECT_DIR}
RUN chown -R user:user /project/{PROJECT_DIR}

USER user
WORKDIR /project/{WORKDIR}

# Set NODE_PATH to resolve from project node_modules first, then base node_modules
# This allows npm to install only missing/incompatible packages in project directory
# while still accessing base packages from /home/user/node_modules
ENV NODE_PATH={NODE_PATH}

RUN /scripts/prepareproject-express.sh

EXPOSE {PORT}

# Run Express app directly using node
CMD ["node", "{ENTRYPOINT}"]

45 changes: 23 additions & 22 deletions baseimages/Dockerfile.node22base
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@ USER user
# Standard packages are selected to benefit most projects while keeping image size reasonable
RUN npm init -y && \
npm install \
# ArangoDB/Foxx core
@arangodb/node-foxx@^0.0.1-alpha.0 \
@arangodb/node-foxx-launcher@^0.0.1-alpha.0 \
@arangodb/arangodb@^0.0.1-alpha.0 \
# Dependency checking utility
semver@^7.6.3 \
# Essential utilities
lodash@^4.17.21 \
dayjs@^1.11.10 \
uuid@^9.0.1 \
dotenv@^16.4.5 \
# HTTP clients
axios@^1.7.2 \
# Validation
joi@^17.13.3 \
# Logging
winston@^3.15.0 \
# Async utilities
async@^3.2.5 \
# Security
jsonwebtoken@^9.0.2 \
bcrypt@^5.1.1
# ArangoDB/Foxx core
@arangodb/node-foxx@^0.0.1-alpha.0 \
@arangodb/node-foxx-launcher@^0.0.1-alpha.0 \
@arangodb/arangodb@^0.0.1-alpha.0 \
arangojs@^10.1.2 \
# Dependency checking utility
semver@^7.6.3 \
# Essential utilities
lodash@^4.17.21 \
dayjs@^1.11.10 \
uuid@^9.0.1 \
dotenv@^16.4.5 \
# HTTP clients
axios@^1.7.2 \
# Validation
joi@^17.13.3 \
# Logging
winston@^3.15.0 \
# Async utilities
async@^3.2.5 \
# Security
jsonwebtoken@^9.0.2 \
bcrypt@^5.1.1

# Create checksums for base node_modules (for tracking, base remains immutable)
RUN find node_modules -type f -print0 | \
Expand Down
4 changes: 4 additions & 0 deletions baseimages/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ if test -e entrypoint ; then
echo "Error: node-foxx not found. Make sure node_modules are installed."
exit 1
fi
elif [ -f "package.json" ] && [ ! -f "services.json" ] && [ ! -f "manifest.json" ] && grep -q '"express"' package.json 2>/dev/null; then
# Express.js application
echo "Detected Express.js application"
exec node $ENTRYPOINT
else
# Python service (existing logic)
echo "Detected Python service"
Expand Down
Loading