Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ailispaw committed Aug 7, 2015
0 parents commit 9d0bfc1
Show file tree
Hide file tree
Showing 22 changed files with 7,657 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
*/.DS_Store

.git/

Makefile
README.md
Vagrantfile
.vagrant/

output/
.ccache/
.dl/
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store

.vagrant/

output/
.ccache/
.dl/
63 changes: 63 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:14.04.2

ENV TERM xterm

RUN apt-get update && \
apt-get install -y ca-certificates curl git && \
apt-get install -y unzip bc wget python xz-utils build-essential libncurses5-dev && \
apt-get install -y syslinux xorriso && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Setup Buildroot
ENV SRCDIR /build
RUN mkdir -p ${SRCDIR}

ENV BUILDROOT_VERSION 2015.05
ENV BUILDROOT ${SRCDIR}/buildroot
RUN cd ${SRCDIR} && \
curl -OL http://buildroot.uclibc.org/downloads/buildroot-${BUILDROOT_VERSION}.tar.bz2 && \
tar xf buildroot-${BUILDROOT_VERSION}.tar.bz2 && \
mv buildroot-${BUILDROOT_VERSION} buildroot && \
rm -f buildroot-${BUILDROOT_VERSION}.tar.bz2

# Setup overlay
ENV OVERLAY /overlay
RUN mkdir -p ${OVERLAY}
WORKDIR ${OVERLAY}

COPY overlay ${OVERLAY}

ENV VERSION 0.9.5
RUN mkdir -p etc && \
echo ${VERSION} > etc/version && \
echo "NAME=\"DockerRoot\"" > etc/os-release && \
echo "VERSION=${VERSION}" >> etc/os-release && \
echo "ID=docker-root" >> etc/os-release && \
echo "ID_LIKE=busybox" >> etc/os-release && \
echo "VERSION_ID=${VERSION}" >> etc/os-release && \
echo "PRETTY_NAME=\"DockerRoot v${VERSION}\"" >> etc/os-release

# Add ca-certificates
RUN mkdir -p etc/ssl/certs && \
cp /etc/ssl/certs/ca-certificates.crt etc/ssl/certs/

# Add Docker
ENV DOCKER_VERSION 1.7.1
RUN mkdir -p bin && \
curl -L https://get.docker.io/builds/Linux/x86_64/docker-${DOCKER_VERSION} \
-o bin/docker && \
chmod +x bin/docker

# Copy config files
COPY configs ${SRCDIR}/configs
RUN cd ${SRCDIR} && \
cp configs/buildroot.config ${BUILDROOT}/.config && \
cp configs/busybox.config ${BUILDROOT}/package/busybox/busybox.config

COPY scripts ${SRCDIR}/scripts

VOLUME ${BUILDROOT}/ccache
VOLUME ${BUILDROOT}/dl

WORKDIR ${BUILDROOT}
CMD ["/build/scripts/build.sh"]
87 changes: 87 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
KERNEL_VERSION := 4.0.9
BUSYBOX_VERSION := 1.23.2

TARGETS := output/rootfs.tar.xz output/bzImage output/docker-root.iso
SOURCES := Dockerfile \
configs/buildroot.config \
configs/busybox.config \
configs/kernel.config \
configs/user.config \
configs/isolinux.cfg \
overlay/etc/profile.d/optbin.sh \
overlay/etc/profile.d/version.sh \
overlay/etc/skel/.wgetrc \
overlay/etc/sudoers.d/docker \
overlay/etc/sysctl.conf \
overlay/init \
overlay/sbin/shutdown \
overlay/usr/bin/respawn \
scripts/build.sh \
scripts/post_build.sh \
scripts/post_image.sh

BUILD_IMAGE := docker-root-builder
BUILD_CONTAINER := docker-root-built

BUILT := `docker ps -aq -f name=$(BUILD_CONTAINER) -f exited=0`

CCACHE_DIR := /mnt/sda1/ccache

all: $(TARGETS)

$(TARGETS): build | output
docker cp $(BUILD_CONTAINER):/build/buildroot/output/images/$(@F) output/

build: $(SOURCES) | .dl
$(eval SRC_UPDATED=$$(shell stat -f "%m" $^ | sort -gr | head -n1))
$(eval STR_CREATED=$$(shell docker inspect -f '{{.Created}}' $(BUILD_IMAGE) 2>/dev/null))
$(eval IMG_CREATED=`date -j -u -f "%F %T" "$$(STR_CREATED)" +"%s" 2>/dev/null || echo 0`)
@if [ "$(SRC_UPDATED)" -gt "$(IMG_CREATED)" ]; then \
set -e; \
docker build -t $(BUILD_IMAGE) .; \
(docker rm -f $(BUILD_CONTAINER) || true); \
fi
@if [ "$(BUILT)" == "" ]; then \
set -e; \
(docker rm -f $(BUILD_CONTAINER) || true); \
docker run -v $(CCACHE_DIR):/build/buildroot/ccache \
-v /vagrant/.dl:/build/buildroot/dl --name $(BUILD_CONTAINER) $(BUILD_IMAGE); \
fi

output .ccache .dl:
mkdir -p $@

clean:
$(RM) -r output
-docker rm -f $(BUILD_CONTAINER)

distclean: clean
$(RM) -r .ccache .dl
-docker rmi $(BUILD_IMAGE)
vagrant destroy -f
$(RM) -r .vagrant

.PHONY: all build clean distclean

vagrant:
-vagrant resume
-vagrant reload
vagrant up --no-provision
vagrant provision
vagrant ssh -c 'sudo mkdir -p $(CCACHE_DIR)'

config: | output
docker cp docker-root-built:/build/buildroot/.config output/
mv output/.config output/buildroot.config
docker cp docker-root-built:/build/buildroot/output/build/busybox-$(BUSYBOX_VERSION)/.config output/
mv output/.config output/busybox.config
docker cp docker-root-built:/build/buildroot/output/build/linux-$(KERNEL_VERSION)/.config output/
mv output/.config output/kernel.config

install:
cp output/bzImage ../rancheros-lite/iso/
cp output/rootfs.tar.xz ../rancheros-lite/iso/
cp output/kernel.config ../rancheros-lite/vboxguest/
cp output/docker-root.iso ../rancheros-lite/

.PHONY: vagrant config install
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# DockerRoot

DockerRoot (formerly [RancherOS Lite](https://github.com/ailispaw/rancheros-lite)) is a lightweight Linux distribution made with [Buildroot](http://buildroot.uclibc.org/) especially to run a [Docker](https://www.docker.com/) daemon as PID 1.

This is inspired by the following projects.

- [Only Docker](https://github.com/ibuildthecloud/only-docker)
- [RancherOS](https://github.com/rancherio/os)
- [RancherOS Base System](https://github.com/rancher/os-base)
- [Boot2Docker](https://github.com/boot2docker/boot2docker)
- [DhyveOS](https://github.com/nlf/dhyve-os)

## Features

- Based on Buildroot 2015.05 with Linux kernel v4.0.9 and GLIBC.
- Runs a Docker daemon as PID 1
- Default username: docker
- Default password: docker
20 changes: 20 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Vagrant.configure(2) do |config|
config.vm.define "docker-root"

config.vm.box = "ailispaw/rancheros-lite"

config.vm.provider :virtualbox do |vb|
vb.memory = 2048
end

config.vm.hostname = "docker-root"

config.vm.network "private_network", ip: "192.168.33.10"

config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ["nolock", "vers=3", "udp"]

# Adjusting datetime before provisioning.
config.vm.provision :shell, run: "always" do |sh|
sh.inline = "sntp -4sSc pool.ntp.org; date"
end
end
Loading

0 comments on commit 9d0bfc1

Please sign in to comment.