Skip to content
Merged
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
102 changes: 69 additions & 33 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Sources/Container-Compose/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ArgumentParser

public struct Main: AsyncParsableCommand {
private static let commandName: String = "container-compose"
private static let version: String = "0.10.0"
private static let version: String = "0.11.0"
public static var versionString: String {
"\(commandName) version \(version)"
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Container-Compose/Commands/ComposeUp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable {

print("Creating network: \(networkName) (Actual name: \(actualNetworkName))")
print("Executing container network create: container \(networkCreateArgs.joined(separator: " "))")
guard (try? await ClientNetwork.get(id: actualNetworkName)) == nil else {
guard (try? await NetworkClient().get(id: actualNetworkName)) == nil else {
print("Network '\(networkName)' already exists")
return
}
Expand Down Expand Up @@ -660,7 +660,7 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable {
commands.append(contentsOf: ["--cpus", "\(cpuCount)"])
commands.append(contentsOf: ["--memory", memoryLimit])

let buildCommand = try Application.BuildCommand.parse(commands)
var buildCommand = try Application.BuildCommand.parse(commands)
print("\n----------------------------------------")
print("Building image for service: \(serviceName) (Tag: \(imageToRun))")
try buildCommand.validate()
Expand Down
110 changes: 55 additions & 55 deletions Tests/Container-Compose-DynamicTests/ComposeUpTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,61 +92,61 @@ struct ComposeUpTests {
}

// TODO: Reenable
// @Test("Test three-tier web application with multiple networks")
// func testThreeTierWebAppWithNetworks() async throws {
// let yaml = DockerComposeYamlFiles.dockerComposeYaml2
//
// let tempLocation = URL.temporaryDirectory.appending(path: "Container-Compose_Tests_\(UUID().uuidString)/docker-compose.yaml")
// try? FileManager.default.createDirectory(at: tempLocation.deletingLastPathComponent(), withIntermediateDirectories: true)
// try yaml.write(to: tempLocation, atomically: false, encoding: .utf8)
// let folderName = tempLocation.deletingLastPathComponent().lastPathComponent
//
// var composeUp = try ComposeUp.parse(["-d", "--cwd", tempLocation.deletingLastPathComponent().path(percentEncoded: false)])
// try await composeUp.run()
//
// // Get the containers created by this compose file
// let containers = try await ContainerClient().list()
// .filter({
// $0.configuration.id.contains(folderName)
// })
//
// guard let nginxContainer = containers.first(where: { $0.configuration.id == "\(folderName)-nginx" }),
// let appContainer = containers.first(where: { $0.configuration.id == "\(folderName)-app" }),
// let dbContainer = containers.first(where: { $0.configuration.id == "\(folderName)-db" }),
// let redisContainer = containers.first(where: { $0.configuration.id == "\(folderName)-redis" })
// else {
// throw Errors.containerNotFound
// }
//
// // --- NGINX Container ---
// #expect(nginxContainer.configuration.image.reference == "docker.io/library/nginx:alpine")
// #expect(nginxContainer.configuration.publishedPorts.map({ "\($0.hostAddress):\($0.hostPort):\($0.containerPort)" }) == ["0.0.0.0:80:80"])
// #expect(nginxContainer.networks.map(\.hostname).contains("frontend"))
//
// // --- APP Container ---
// #expect(appContainer.configuration.image.reference == "docker.io/library/node:18-alpine")
//
// let appEnv = parseEnvToDict(appContainer.configuration.initProcess.environment)
// #expect(appEnv["NODE_ENV"] == "production")
// #expect(appEnv["DATABASE_URL"] == "postgres://\(dbContainer.networks.first!.address.split(separator: "/")[0]):5432/myapp")
//
// #expect(appContainer.networks.map(\.hostname).sorted() == ["backend", "frontend"])
//
// // --- DB Container ---
// #expect(dbContainer.configuration.image.reference == "docker.io/library/postgres:14-alpine")
// let dbEnv = parseEnvToDict(dbContainer.configuration.initProcess.environment)
// #expect(dbEnv["POSTGRES_DB"] == "myapp")
// #expect(dbEnv["POSTGRES_USER"] == "user")
// #expect(dbEnv["POSTGRES_PASSWORD"] == "password")
//
// // Verify volume mount
// #expect(dbContainer.configuration.mounts.map(\.destination) == ["/var/lib/postgresql/"])
// #expect(dbContainer.networks.map(\.hostname) == ["backend"])
//
// // --- Redis Container ---
// #expect(redisContainer.configuration.image.reference == "docker.io/library/redis:alpine")
// #expect(redisContainer.networks.map(\.hostname) == ["backend"])
// }
// @Test("Test three-tier web application with multiple networks")
// func testThreeTierWebAppWithNetworks() async throws {
// let yaml = DockerComposeYamlFiles.dockerComposeYaml2
//
// let tempLocation = URL.temporaryDirectory.appending(path: "Container-Compose_Tests_\(UUID().uuidString)/docker-compose.yaml")
// try? FileManager.default.createDirectory(at: tempLocation.deletingLastPathComponent(), withIntermediateDirectories: true)
// try yaml.write(to: tempLocation, atomically: false, encoding: .utf8)
// let folderName = tempLocation.deletingLastPathComponent().lastPathComponent
//
// var composeUp = try ComposeUp.parse(["-d", "--cwd", tempLocation.deletingLastPathComponent().path(percentEncoded: false)])
// try await composeUp.run()
//
// // Get the containers created by this compose file
// let containers = try await ContainerClient().list()
// .filter({
// $0.configuration.id.contains(folderName)
// })
//
// guard let nginxContainer = containers.first(where: { $0.configuration.id == "\(folderName)-nginx" }),
// let appContainer = containers.first(where: { $0.configuration.id == "\(folderName)-app" }),
// let dbContainer = containers.first(where: { $0.configuration.id == "\(folderName)-db" }),
// let redisContainer = containers.first(where: { $0.configuration.id == "\(folderName)-redis" })
// else {
// throw Errors.containerNotFound
// }
//
// // --- NGINX Container ---
// #expect(nginxContainer.configuration.image.reference == "docker.io/library/nginx:alpine")
// #expect(nginxContainer.configuration.publishedPorts.map({ "\($0.hostAddress):\($0.hostPort):\($0.containerPort)" }) == ["0.0.0.0:80:80"])
// #expect(nginxContainer.networks.map(\.hostname).contains("frontend"))
//
// // --- APP Container ---
// #expect(appContainer.configuration.image.reference == "docker.io/library/node:18-alpine")
//
// let appEnv = parseEnvToDict(appContainer.configuration.initProcess.environment)
// #expect(appEnv["NODE_ENV"] == "production")
// #expect(appEnv["DATABASE_URL"] == "postgres://\(dbContainer.networks.first!.ipv4Gateway.description):5432/myapp")
//
// #expect(appContainer.networks.map(\.hostname).sorted() == ["backend", "frontend"])
//
// // --- DB Container ---
// #expect(dbContainer.configuration.image.reference == "docker.io/library/postgres:14-alpine")
// let dbEnv = parseEnvToDict(dbContainer.configuration.initProcess.environment)
// #expect(dbEnv["POSTGRES_DB"] == "myapp")
// #expect(dbEnv["POSTGRES_USER"] == "user")
// #expect(dbEnv["POSTGRES_PASSWORD"] == "password")
//
// // Verify volume mount
// #expect(dbContainer.configuration.mounts.map(\.destination) == ["/var/lib/postgresql/"])
// #expect(dbContainer.networks.map(\.hostname) == ["backend"])
//
// // --- Redis Container ---
// #expect(redisContainer.configuration.image.reference == "docker.io/library/redis:alpine")
// #expect(redisContainer.networks.map(\.hostname) == ["backend"])
// }

// @Test("Parse development environment with build")
// func parseDevelopmentEnvironment() throws {
Expand Down
Loading