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
19 changes: 18 additions & 1 deletion .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,28 @@ on:
- release/*

jobs:
swift-version:
name: Determine Swift version
runs-on: ubuntu-24.04
outputs:
image: ${{ steps.version.outputs.image }}
steps:
- name: Checkout .swift-version
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
sparse-checkout: .swift-version
sparse-checkout-cone-mode: false

- name: Read Swift version
id: version
run: echo "image=swift:$(cat .swift-version)-noble" >> "$GITHUB_OUTPUT"

build:
name: Linux compile check
needs: swift-version
timeout-minutes: 30
runs-on: ubuntu-24.04
container: swift:6.3-noble
container: ${{ needs.swift-version.outputs.image }}

steps:
- name: Checkout repository
Expand Down
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ LIBARCHIVE_LOCAL_DIR := workdir/libarchive

KATA_BINARY_PACKAGE := https://github.com/kata-containers/kata-containers/releases/download/3.17.0/kata-static-3.17.0-arm64.tar.xz

SWIFT_VERSION := $(shell cat $(ROOT_DIR)/.swift-version)
SWIFT_SDK_URL := $(shell grep '^SWIFT_SDK_URL' vminitd/Makefile | head -1 | sed 's/.*:= *//')
SWIFT_SDK_CHECKSUM := $(shell grep '^SWIFT_SDK_CHECKSUM' vminitd/Makefile | head -1 | sed 's/.*:= *//')
LINUX_DEV_IMAGE := containerization-dev:$(SWIFT_VERSION)

# Run a command inside a Linux dev container.
# Requires 'container' (https://github.com/apple/container).
# Automatically builds the dev image if it doesn't exist.
define linux_run
@if ! command -v container > /dev/null 2>&1; then \
echo "Error: 'container' CLI not found. Install from https://github.com/apple/container"; \
exit 1; \
fi
@if ! container image list -q 2>/dev/null | grep -q "$(LINUX_DEV_IMAGE)"; then \
echo "Building Linux dev container image..."; \
$(MAKE) linux-image; \
fi
@container run --memory 8gb --cpus 4 -v $(ROOT_DIR):/workspace -w /workspace $(LINUX_DEV_IMAGE) \
bash -c "$(1)"
endef

include Protobuf.Makefile
.DEFAULT_GOAL := all

Expand All @@ -48,6 +69,28 @@ else
@echo "No additional dependencies required on $(UNAME_S)"
endif

ifeq ($(UNAME_S),Darwin)
.PHONY: linux-image
linux-image:
container build \
--progress plain \
-f images/linux-dev/Dockerfile \
--build-arg SWIFT_VERSION=$(SWIFT_VERSION) \
--build-arg SWIFT_SDK_URL=$(SWIFT_SDK_URL) \
--build-arg SWIFT_SDK_CHECKSUM=$(SWIFT_SDK_CHECKSUM) \
-t $(LINUX_DEV_IMAGE) \
.

.PHONY: linux-build
linux-build: LIBC ?= musl
linux-build:
ifeq ($(LIBC),all)
$(call linux_run,make containerization && make -C vminitd LIBC=glibc && make -C vminitd LIBC=musl)
else
$(call linux_run,make containerization && make -C vminitd LIBC=$(LIBC))
endif
endif

.PHONY: all
all: containerization
all: init
Expand Down
27 changes: 27 additions & 0 deletions images/linux-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright © 2026 Apple Inc. and the Containerization project authors.
#
# 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.

ARG SWIFT_VERSION=6.3
FROM swift:${SWIFT_VERSION}-noble

RUN apt-get update \
&& apt-get install -y make libarchive-dev libbz2-dev liblzma-dev libssl-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG SWIFT_SDK_URL
ARG SWIFT_SDK_CHECKSUM
RUN if [ -n "$SWIFT_SDK_URL" ]; then \
swift sdk install "$SWIFT_SDK_URL" --checksum "$SWIFT_SDK_CHECKSUM"; \
fi
2 changes: 1 addition & 1 deletion vminitd/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM swift:6.2
FROM swift:6.3-noble

RUN apt-get update \
&& apt-get install make \
Expand Down
7 changes: 6 additions & 1 deletion vminitd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ else
MUSL_ARCH := x86_64
endif

SWIFT_CONFIGURATION := --swift-sdk $(MUSL_ARCH)-swift-linux-musl $(SWIFT_WARNING_CONFIG) -Xlinker -s --disable-automatic-resolution
LIBC ?= musl
ifeq ($(LIBC),musl)
SWIFT_SDK_FLAGS := --swift-sdk $(MUSL_ARCH)-swift-linux-musl
endif

SWIFT_CONFIGURATION := $(SWIFT_SDK_FLAGS) $(SWIFT_WARNING_CONFIG) -Xlinker -s --disable-automatic-resolution

SWIFT_VERSION := 6.3
SWIFT_SDK_URL := https://download.swift.org/swift-6.3-release/static-sdk/swift-6.3-RELEASE/swift-6.3-RELEASE_static-linux-0.1.0.artifactbundle.tar.gz
Expand Down
Loading