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
4 changes: 2 additions & 2 deletions engine/src/cli/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ async fn run_generate_docker(args: GenerateDockerArgs) -> i32 {
/// The Dockerfile template carries a literal `__III_DEVICE_ID__` placeholder
/// that we substitute with the actual device_id before writing, so the image
/// no longer needs an `III_HOST_USER_ID` env var at runtime. The generated
/// `.env` only carries the RabbitMQ password (used by the commented-out
/// rabbitmq service in docker-compose.yml).
/// `.env` carries RabbitMQ credentials that the engine reads while expanding
/// `${VAR}` placeholders and that the commented-out RabbitMQ service can use.
const DEVICE_ID_PLACEHOLDER: &str = "__III_DEVICE_ID__";

async fn apply_docker(
Expand Down
1 change: 1 addition & 0 deletions engine/tests/fixtures/templates/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- "9464:9464" # Prometheus metrics
volumes:
- ./config.yaml:/app/config.yaml:ro
env_file: .env
environment:
- RUST_LOG=info
- III_EXECUTION_CONTEXT=docker
Expand Down
10 changes: 10 additions & 0 deletions engine/tests/project_init_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ fn fixtures() -> PathBuf {
.join("templates")
}

fn assert_compose_reads_env_file(project_dir: &Path) {
let compose = std::fs::read_to_string(project_dir.join("docker-compose.yml")).unwrap();
assert!(
compose.contains("env_file: .env"),
"docker-compose.yml should pass the generated .env into the engine container, got:\n{compose}"
);
}

#[test]
fn project_init_creates_minimum_scaffold() {
let dir = tempdir().unwrap();
Expand Down Expand Up @@ -164,6 +172,7 @@ fn project_init_with_docker_flag_writes_docker_assets_with_device_id() {
assert!(dir.path().join("Dockerfile").exists());
assert!(dir.path().join("docker-compose.yml").exists());
assert!(dir.path().join(".env").exists());
assert_compose_reads_env_file(dir.path());

let ini = std::fs::read_to_string(dir.path().join(".iii").join("project.ini")).unwrap();
let device_id_in_ini = ini
Expand Down Expand Up @@ -217,6 +226,7 @@ fn project_generate_docker_uses_existing_project_ini_device_id() {
dockerfile.contains("ENV III_HOST_USER_ID=preseeded-xyz"),
"Dockerfile should bake the existing device_id, got:\n{dockerfile}"
);
assert_compose_reads_env_file(dir.path());

let env = std::fs::read_to_string(dir.path().join(".env")).unwrap();
assert!(
Expand Down
Loading