diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..c96e1fe01 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,42 @@ +# Copyright The containerd 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 + +# http://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. + +# For details, see https://github.com/devcontainers/images/tree/main/src/base-ubuntu +FROM mcr.microsoft.com/devcontainers/base:1-ubuntu-22.04 + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + gperf \ + dmsetup \ + bc \ + software-properties-common \ + libseccomp-dev \ + xfsprogs \ + lsof \ + iptables \ + autoconf \ + automake \ + g++ \ + libtool \ + acl \ + && rm -rf /var/lib/apt/lists/* + +RUN add-apt-repository -y ppa:criu/ppa \ + && apt-get update \ + && apt-get install -y criu \ + && rm -rf /var/lib/apt/lists/* + +RUN setfacl -PRdm u::rwx,g::rx,o::rx /tmp + +COPY .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..cfda8a3fa --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// For format details, see https://aka.ms/devcontainer.json. +{ + "name": "containerd", + "build": { + "context": "..", + "dockerfile": "Dockerfile" + }, + "workspaceFolder": "/go/src/github.com/containerd/containerd", + "workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/containerd/containerd,type=bind,consistency=cached", + + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/go:1": { + "version": "1.20" + } + }, + + "onCreateCommand": "sudo PATH=$PATH bash .devcontainer/setup.sh", + "postAttachCommand": { + "Runs all non-integration tests that do not require `root` privileges": "make test", + "Runs non-integration tests which require `root`": "sudo PATH=$PATH make root-test" + }, + + "remoteUser": "root", + "runArgs": [ + "--ipc=host", + "--volume=/dev:/dev", + "--volume=/run/udev:/run/udev", + "--privileged" + ] +} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 000000000..4446f39c8 --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright The containerd 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 + +# http://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. + +set -eux + +script/setup/install-seccomp +script/setup/install-runc +script/setup/install-cni $(grep containernetworking/plugins go.mod | awk '{print $2}') +script/setup/install-critools +script/setup/install-failpoint-binaries +script/setup/install-gotestsum +script/setup/install-teststat + +script/setup/install-protobuf \ + && mkdir -p /go/src/usr/local/bin /go/src/usr/local/include \ + && mv /usr/local/bin/protoc /go/src/usr/local/bin/protoc \ + && mv /usr/local/include/google /go/src/usr/local/include/google + +make binaries GO_BUILD_FLAGS="-mod=vendor" +sudo -E PATH=$PATH make install diff --git a/.devcontainer/welcome-message.txt b/.devcontainer/welcome-message.txt new file mode 100644 index 000000000..fd6ad2d22 --- /dev/null +++ b/.devcontainer/welcome-message.txt @@ -0,0 +1,7 @@ +👋 Welcome to "containerd" in GitHub Codespaces! + +đŸ› ī¸ Your environment is fully setup with all the required software. + +🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1). + +â„šī¸ Look at https://github.com/containerd/project/blob/main/CONTRIBUTING.md for contribution guidelines. diff --git a/BUILDING.md b/BUILDING.md index 6ee12f79f..70c9dbc98 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -4,12 +4,23 @@ This guide is useful if you intend to contribute on containerd. Thanks for your effort. Every contribution is very appreciated. This doc includes: +* [Getting started with GitHub Codespaces](#getting-started-with-gitHub-codespaces) * [Build requirements](#build-requirements) * [Build the development environment](#build-the-development-environment) * [Build containerd](#build-containerd) * [Via docker container](#via-docker-container) * [Testing](#testing-containerd) +## Getting started with GitHub Codespaces + +To get started, create a codespace for this repository by clicking this 👇 + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=46089560) + +A codespace will open in a web-based version of Visual Studio Code. The [dev container](.devcontainer/devcontainer.json) is fully configured with software needed for this project and the containerd built. If you use a codespace, then you can directly skip to the [testing](#testing-containerd) section of this document. + +**Note**: Dev containers is an open spec which is supported by [GitHub Codespaces](https://github.com/codespaces) and [other tools](https://containers.dev/supporting). + ## Build requirements To build the `containerd` daemon, and the `ctr` simple test client, the following build system dependencies are required: