Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
0b86489
add compose to cli
Mcrich23 Jun 19, 2025
2f6995a
build optimization fix
Mcrich23 Jun 19, 2025
316e136
Formatting fixes
Mcrich23 Jun 19, 2025
3f8a30a
update compose command entrypoint
Mcrich23 Jun 19, 2025
d69c7b0
updated to fix image pulling and add color coding to image operations…
Mcrich23 Jun 19, 2025
7a74024
update formatting
Mcrich23 Jun 19, 2025
88ce26c
update descriptions
Mcrich23 Jun 19, 2025
c39a58a
update compose codable structs to have docc documentation
Mcrich23 Jun 20, 2025
572bd50
added service specification to compose if desired
Mcrich23 Jun 20, 2025
4ba586e
Update ComposeUp.swift
Mcrich23 Jun 20, 2025
77c751d
Update ComposeDown.swift
Mcrich23 Jun 20, 2025
bd52066
Merge branch 'main' into add-compose
Mcrich23 Jun 20, 2025
9da6554
Merge branch 'main' into add-compose
Mcrich23 Jun 24, 2025
8f21c47
Merge branch 'main' into add-compose
Mcrich23 Jul 4, 2025
e483a93
Merge branch 'main' into add-compose
Mcrich23 Jul 8, 2025
7e174d0
Moved compose to be within Application struct
Mcrich23 Jul 8, 2025
ab643d8
Access control fixes
Mcrich23 Jul 8, 2025
28ee0d2
update network setup function
Mcrich23 Jul 8, 2025
1ee92a6
add networking support
Mcrich23 Jul 8, 2025
e09b012
warning fixes
Mcrich23 Jul 8, 2025
acf7c8b
access control fixes
Mcrich23 Jul 8, 2025
11cacaf
Begin update of functions using internal controls instead of runCommand
Mcrich23 Jul 9, 2025
5a50472
updated network and image pull to use internal tools
Mcrich23 Jul 9, 2025
10e1ed5
add platform support for image pulling for services
Mcrich23 Jul 9, 2025
0b0d68d
preliminary update build to use internal tooling
Mcrich23 Jul 9, 2025
630e288
image build fixes
Mcrich23 Jul 9, 2025
7306ba4
Update ComposeUp.swift
Mcrich23 Jul 9, 2025
8acd11f
code cleanup
Mcrich23 Jul 9, 2025
c7936d9
Update ComposeUp.swift
Mcrich23 Jul 9, 2025
0ef6fbd
access control updates
Mcrich23 Jul 9, 2025
4c517c5
Update Package.swift
Mcrich23 Jul 9, 2025
7b7a0ab
exposed CLI as product
Mcrich23 Jul 9, 2025
1d9704f
copy cli to container cli
Mcrich23 Jul 9, 2025
e21bdf9
Update Package.swift
Mcrich23 Jul 9, 2025
71fbefe
Revert "copy cli to container cli"
Mcrich23 Jul 9, 2025
8e70e81
Update Package.swift
Mcrich23 Jul 9, 2025
0894611
Update ContainerCLI
Mcrich23 Jul 9, 2025
159ce20
expose cli fixes
Mcrich23 Jul 9, 2025
237b028
Moved container executable to its own file, allowing the exposure of …
Mcrich23 Jul 9, 2025
826523d
Moved container executable to its own file, allowing the exposure of …
Mcrich23 Jul 9, 2025
e0cbd6e
Merge branch 'main' into add-compose
Mcrich23 Jul 9, 2025
4c591a4
Merge branch 'main' into add-compose
Mcrich23 Jul 16, 2025
7ca17a2
Revert "Moved container executable to its own file, allowing the expo…
Mcrich23 Jul 16, 2025
1b329d9
Revert "Moved container executable to its own file, allowing the expo…
Mcrich23 Jul 16, 2025
a359cf3
Revert "expose cli fixes"
Mcrich23 Jul 16, 2025
8665d48
Revert "Update ContainerCLI"
Mcrich23 Jul 16, 2025
030830b
Revert "Update Package.swift"
Mcrich23 Jul 16, 2025
2924fc0
Reapply "copy cli to container cli"
Mcrich23 Jul 16, 2025
909f173
Revert "Update Package.swift"
Mcrich23 Jul 16, 2025
59ec9dd
Revert "copy cli to container cli"
Mcrich23 Jul 16, 2025
c76dd7a
Revert "exposed CLI as product"
Mcrich23 Jul 16, 2025
a371c82
Revert "Update Package.swift"
Mcrich23 Jul 16, 2025
3445fe3
Update Package.swift
Mcrich23 Jul 16, 2025
bd19de1
moved Compose to plugin format
Mcrich23 Jul 16, 2025
82a2332
Create compose-config.json
Mcrich23 Jul 16, 2025
0cb47d3
add compose install to make file
Mcrich23 Jul 16, 2025
e24e048
Update ComposeCommand.swift
Mcrich23 Jul 16, 2025
b960fdf
access control fixes
Mcrich23 Jul 16, 2025
e9d2926
swift concurrency fix
Mcrich23 Jul 16, 2025
d2186ed
Update BuildCommand.swift
Mcrich23 Jul 16, 2025
c5fe1d4
Reapply "Update Package.swift"
Mcrich23 Jul 16, 2025
a44bcc1
Reapply "exposed CLI as product"
Mcrich23 Jul 16, 2025
970c884
Reapply "copy cli to container cli"
Mcrich23 Jul 16, 2025
5c299c5
Reapply "Update Package.swift"
Mcrich23 Jul 16, 2025
7f690ef
Revert "Reapply "copy cli to container cli""
Mcrich23 Jul 16, 2025
aecc92b
Reapply "Update Package.swift"
Mcrich23 Jul 16, 2025
d7206c6
Reapply "Update ContainerCLI"
Mcrich23 Jul 16, 2025
23728e5
Reapply "expose cli fixes"
Mcrich23 Jul 16, 2025
1ff103a
Reapply "Moved container executable to its own file, allowing the exp…
Mcrich23 Jul 16, 2025
119fd44
Reapply "Moved container executable to its own file, allowing the exp…
Mcrich23 Jul 16, 2025
4162514
linker fixes?
Mcrich23 Jul 16, 2025
4518172
Access control fixes
Mcrich23 Jul 16, 2025
e7ce752
update makefile to install compose as plugin
Mcrich23 Jul 17, 2025
466ffb7
Merge branch 'main' into add-compose
Mcrich23 Jul 19, 2025
6d9a5f5
Merge branch 'main' into add-compose
Mcrich23 Jul 19, 2025
ad01579
Merge branch 'main' into add-compose
Mcrich23 Jul 23, 2025
28ef682
Merge branch 'main' into add-compose
Mcrich23 Jul 25, 2025
7c256c6
Update ComposeUp.swift
Mcrich23 Jul 25, 2025
248b667
Argument parsing fixes
Mcrich23 Jul 25, 2025
3c9afd9
Argument parsing fixes
Mcrich23 Jul 25, 2025
958274c
depends_on fixes
Mcrich23 Jul 25, 2025
8b1e27f
added docker-compose file yaml vs yml automatic extension switching
Mcrich23 Jul 25, 2025
d309b48
formatting and header fixes
Mcrich23 Jul 25, 2025
7954ad5
Merge branch 'apple:main' into add-compose
Mcrich23 Aug 21, 2025
1562dbf
expose ComposeCLI functions separately from executable
Mcrich23 Aug 21, 2025
1e74e16
Update Package.swift
Mcrich23 Aug 21, 2025
f489307
Update Package.swift
Mcrich23 Aug 21, 2025
5fcf368
merge expose-command-structs-for-plugins to test new plugin system
Mcrich23 Sep 14, 2025
be1c392
make CLI option groups public properties
Mcrich23 Sep 14, 2025
d1147f2
update ComposeUp to use parse functions for CLI commands
Mcrich23 Sep 14, 2025
b32f14c
Support compose.yml filenames (#1)
adrum Sep 14, 2025
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
33 changes: 31 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export GIT_COMMIT := $(shell git rev-parse HEAD)
SWIFT := "/usr/bin/swift"
DESTDIR ?= /usr/local/
ROOT_DIR := $(shell git rev-parse --show-toplevel)
BUILD_BIN_DIR = $(shell $(SWIFT) build -c $(BUILD_CONFIGURATION) --show-bin-path)
BUILD_BIN_DIR := .build/$(BUILD_CONFIGURATION)
STAGING_DIR := bin/$(BUILD_CONFIGURATION)/staging/
PKG_PATH := bin/$(BUILD_CONFIGURATION)/container-installer-unsigned.pkg
DSYM_DIR := bin/$(BUILD_CONFIGURATION)/bundle/container-dSYM
Expand All @@ -44,7 +44,7 @@ SUDO ?= sudo
include Protobuf.Makefile

.PHONY: all
all: container
all: container compose
all: init-block

.PHONY: build
Expand All @@ -57,6 +57,10 @@ build:
container: build
@"$(MAKE)" BUILD_CONFIGURATION=$(BUILD_CONFIGURATION) DESTDIR="$(ROOT_DIR)/" SUDO= install

.PHONY: compose
compose: build
@"$(MAKE)" BUILD_CONFIGURATION=$(BUILD_CONFIGURATION) DESTDIR=$(ROOT_DIR)/ SUDO= install-compose

.PHONY: release
release: BUILD_CONFIGURATION = release
release: all
Expand Down Expand Up @@ -110,6 +114,31 @@ installer-pkg: $(STAGING_DIR)
@pkgbuild --root "$(STAGING_DIR)" --identifier com.apple.container-installer --install-location /usr/local --version ${RELEASE_VERSION} $(PKG_PATH)
@rm -rf "$(STAGING_DIR)"

################################################################################
# Compose plugin install targets
################################################################################

COMPOSE_STAGING_DIR := bin/$(BUILD_CONFIGURATION)/compose-staging/

.PHONY: install-compose
install-compose: compose-staging
@echo Installing compose plugin to $(DESTDIR)...
@$(SUDO) mkdir -p $(DESTDIR)/libexec/container/plugins/compose/bin
@$(SUDO) install $(BUILD_BIN_DIR)/compose $(DESTDIR)/libexec/container/plugins/compose/bin/compose
@$(SUDO) install config/compose-config.json $(DESTDIR)/libexec/container/plugins/compose/config.json
@$(SUDO) install scripts/uninstall-compose.sh $(DESTDIR)/libexec/container/plugins/compose/bin/uninstall-compose.sh
@$(SUDO) codesign $(CODESIGN_OPTS) $(DESTDIR)/libexec/container/plugins/compose/bin/compose

compose-staging:
@echo Staging compose plugin binaries to $(COMPOSE_STAGING_DIR)...
@rm -rf $(COMPOSE_STAGING_DIR)
@mkdir -p $(COMPOSE_STAGING_DIR)/libexec/container/plugins/compose/bin
@install $(BUILD_BIN_DIR)/container $(COMPOSE_STAGING_DIR)/libexec/container/plugins/compose/bin/compose
@install config/compose-config.json $(COMPOSE_STAGING_DIR)/libexec/container/plugins/compose/config.json
@install scripts/uninstall-compose.sh $(COMPOSE_STAGING_DIR)/libexec/container/plugins/compose/bin/uninstall-compose.sh

################################################################################

.PHONY: dsym
dsym:
@echo Copying debug symbols...
Expand Down
18 changes: 18 additions & 0 deletions Package.resolved

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

35 changes: 35 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let package = Package(
.library(name: "ContainerNetworkService", targets: ["ContainerNetworkService"]),
.library(name: "ContainerImagesService", targets: ["ContainerImagesService", "ContainerImagesServiceClient"]),
.library(name: "ContainerClient", targets: ["ContainerClient"]),
.library(name: "ContainerCLI", targets: ["ContainerCLI"]),
.library(name: "ContainerBuild", targets: ["ContainerBuild"]),
.library(name: "ContainerLog", targets: ["ContainerLog"]),
.library(name: "ContainerPersistence", targets: ["ContainerPersistence"]),
Expand All @@ -46,6 +47,7 @@ let package = Package(
.library(name: "ContainerBuildCache", targets: ["ContainerBuildCache"]),
.library(name: "ContainerBuildSnapshotter", targets: ["ContainerBuildSnapshotter"]),
.library(name: "ContainerBuildParser", targets: ["ContainerBuildParser"]),
.library(name: "ComposeCLI", targets: ["ComposeCLI"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
Expand All @@ -59,11 +61,22 @@ let package = Package(
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.20.1"),
.package(url: "https://github.com/orlandos-nl/DNSClient.git", from: "2.4.1"),
.package(url: "https://github.com/Bouke/DNS.git", from: "1.2.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"),
.package(url: "https://github.com/onevcat/Rainbow", .upToNextMajor(from: "4.0.0")),
.package(url: "https://github.com/apple/containerization.git", exact: Version(stringLiteral: scVersion)),
],
targets: [
.executableTarget(
name: "container",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"ContainerClient",
"ContainerCLI",
],
path: "Sources/ExecutableCLI"
),
.target(
name: "ContainerCLI",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Logging", package: "swift-log"),
Expand Down Expand Up @@ -432,5 +445,27 @@ let package = Package(
.define("BUILDER_SHIM_VERSION", to: "\"\(builderShimVersion)\""),
]
),

// MARK: Plugins
.target(
name: "ComposeCLI",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"container",
"ContainerCLI",
"Yams",
"Rainbow",
],
path: "Plugins/Compose/ComposeCLI"
),

.executableTarget(
name: "compose",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"ComposeCLI"
],
path: "Plugins/Compose/compose"
),
]
)
52 changes: 52 additions & 0 deletions Plugins/Compose/ComposeCLI/Codable Structs/Build.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
// Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

//
// Build.swift
// container-compose-app
//
// Created by Morris Richman on 6/17/25.
//


/// Represents the `build` configuration for a service.
struct Build: Codable, Hashable {
/// Path to the build context
let context: String
/// Optional path to the Dockerfile within the context
let dockerfile: String?
/// Build arguments
let args: [String: String]?

/// Custom initializer to handle `build: .` (string) or `build: { context: . }` (object)
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let contextString = try? container.decode(String.self) {
self.context = contextString
self.dockerfile = nil
self.args = nil
} else {
let keyedContainer = try decoder.container(keyedBy: CodingKeys.self)
self.context = try keyedContainer.decode(String.self, forKey: .context)
self.dockerfile = try keyedContainer.decodeIfPresent(String.self, forKey: .dockerfile)
self.args = try keyedContainer.decodeIfPresent([String: String].self, forKey: .args)
}
}

enum CodingKeys: String, CodingKey {
case context, dockerfile, args
}
}
55 changes: 55 additions & 0 deletions Plugins/Compose/ComposeCLI/Codable Structs/Config.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
// Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

//
// Config.swift
// container-compose-app
//
// Created by Morris Richman on 6/17/25.
//


/// Represents a top-level config definition (primarily for Swarm).
struct Config: Codable {
/// Path to the file containing the config content
let file: String?
/// Indicates if the config is external (pre-existing)
let external: ExternalConfig?
/// Explicit name for the config
let name: String?
/// Labels for the config
let labels: [String: String]?

enum CodingKeys: String, CodingKey {
case file, external, name, labels
}

/// Custom initializer to handle `external: true` (boolean) or `external: { name: "my_cfg" }` (object).
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
file = try container.decodeIfPresent(String.self, forKey: .file)
name = try container.decodeIfPresent(String.self, forKey: .name)
labels = try container.decodeIfPresent([String: String].self, forKey: .labels)

if let externalBool = try? container.decodeIfPresent(Bool.self, forKey: .external) {
external = ExternalConfig(isExternal: externalBool, name: nil)
} else if let externalDict = try? container.decodeIfPresent([String: String].self, forKey: .external) {
external = ExternalConfig(isExternal: true, name: externalDict["name"])
} else {
external = nil
}
}
}
35 changes: 35 additions & 0 deletions Plugins/Compose/ComposeCLI/Codable Structs/Deploy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
// Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

//
// Deploy.swift
// container-compose-app
//
// Created by Morris Richman on 6/17/25.
//


/// Represents the `deploy` configuration for a service (primarily for Swarm orchestration).
struct Deploy: Codable, Hashable {
/// Deployment mode (e.g., 'replicated', 'global')
let mode: String?
/// Number of replicated service tasks
let replicas: Int?
/// Resource constraints (limits, reservations)
let resources: DeployResources?
/// Restart policy for tasks
let restart_policy: DeployRestartPolicy?
}
31 changes: 31 additions & 0 deletions Plugins/Compose/ComposeCLI/Codable Structs/DeployResources.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
// Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

//
// DeployResources.swift
// container-compose-app
//
// Created by Morris Richman on 6/17/25.
//


/// Resource constraints for deployment.
struct DeployResources: Codable, Hashable {
/// Hard limits on resources
let limits: ResourceLimits?
/// Guarantees for resources
let reservations: ResourceReservations?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
// Copyright © 2025 Apple Inc. and the container project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//

//
// DeployRestartPolicy.swift
// container-compose-app
//
// Created by Morris Richman on 6/17/25.
//


/// Restart policy for deployed tasks.
struct DeployRestartPolicy: Codable, Hashable {
/// Condition to restart on (e.g., 'on-failure', 'any')
let condition: String?
/// Delay before attempting restart
let delay: String?
/// Maximum number of restart attempts
let max_attempts: Int?
/// Window to evaluate restart policy
let window: String?
}
Loading