Skip to content

Commit a51d0d2

Browse files
author
Matthew Fisher
committed
import submodules into project
1 parent d741c5f commit a51d0d2

86 files changed

Lines changed: 2952 additions & 32 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 0 additions & 24 deletions
This file was deleted.

builder/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM deis/base:latest
2+
MAINTAINER Gabriel Monroy <gabriel@opdemand.com>
3+
4+
ENV DEBIAN_FRONTEND noninteractive
5+
6+
# install ssh server
7+
RUN apt-get install -yq openssh-server
8+
RUN rm /etc/ssh/ssh_host_*
9+
RUN dpkg-reconfigure openssh-server
10+
RUN mkdir -p /var/run/sshd
11+
12+
# install docker in docker deps
13+
RUN apt-get install -yq aufs-tools iptables ca-certificates lxc
14+
RUN echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
15+
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
16+
RUN apt-get update -q
17+
RUN apt-get install -yq lxc-docker-0.8.0
18+
19+
# install hook dependencies
20+
RUN apt-get install -yq python-pip
21+
RUN pip install pyyaml requests
22+
23+
# install hook utilities
24+
RUN apt-get install -yq curl vim
25+
26+
# install all i18n locales
27+
RUN ln -s /usr/share/i18n/SUPPORTED /var/lib/locales/supported.d/all && locale-gen
28+
29+
# install git and configure gituser
30+
ENV GITHOME /home/git
31+
ENV GITUSER git
32+
RUN apt-get install -yq git
33+
RUN useradd -d $GITHOME $GITUSER
34+
RUN mkdir -p $GITHOME/.ssh && chown git:git $GITHOME/.ssh
35+
RUN chown -R $GITUSER:$GITUSER $GITHOME
36+
37+
# let the git user run `sudo /home/git/builder` (not writeable)
38+
RUN apt-get install -yq sudo
39+
RUN echo "%git ALL=(ALL:ALL) NOPASSWD:/home/git/builder" >> /etc/sudoers
40+
41+
# install custom confd
42+
RUN wget -q https://s3-us-west-2.amazonaws.com/deis/confd -O /usr/local/bin/confd
43+
RUN chmod +x /usr/local/bin/confd
44+
45+
# add the current build context to /app
46+
ADD . /app
47+
RUN chown -R root:root /app
48+
49+
# define the execution environment
50+
VOLUME /var/lib/docker
51+
ENTRYPOINT ["/app/bin/entry"]
52+
CMD ["/app/bin/boot"]
53+
EXPOSE 22

builder/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
build:
2+
docker build -t deis/builder .
3+
4+
config:
5+
-etcdctl -C $${ETCD:-127.0.0.1:4001} setdir /deis
6+
-etcdctl -C $${ETCD:-127.0.0.1:4001} setdir /deis/builder
7+
etcdctl -C $${ETCD:-127.0.0.1:4001} set /deis/builder/port $${PORT:-22}
8+
9+
run:
10+
docker run -privileged -e ETCD=$${ETCD:-127.0.0.1:4001} -p $${PORT:-2222}:$${PORT:-22} -rm deis/builder ; exit 0
11+
12+
shell:
13+
docker run -privileged -e $${ETCD:-127.0.0.1:4001} -t -i -rm deis/builder /bin/bash
14+
15+
clean:
16+
-docker rmi deis/builder

builder/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Deis Builder
2+
3+
A Docker image that builds Docker images, for use in the [Deis](http://deis.io) open source PaaS.
4+
5+
[![image](https://d207aa93qlcgug.cloudfront.net/img/icons/framed-icon-checked-repository.svg)](https://index.docker.io/u/deis/builder/)
6+
7+
[**Trusted Build**](https://index.docker.io/u/deis/builder/)
8+
9+
This Docker image is based on the trusted build [deis/base](https://index.docker.io/u/deis/base/), which itself is based on the official [ubuntu:12.04](https://index.docker.io/_/ubuntu/) base image.
10+
11+
Please add any issues you find with this software to the parent [Deis project](https://github.com/opdemand/deis/issues).
12+
13+
## Usage
14+
15+
Coming Soon!
16+
17+
## License
18+
19+
Copyright 2014 OpDemand LLC
20+
21+
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>
22+
23+
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.

builder/authorized_keys

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
command="/app/gitreceive run gabrtv 88:25:ed:67:56:91:3d:c6:1b:7f:42:c6:9b:41:24:80",no-agent-forwarding,no-pty,no-user-rc,no-X11-forwarding,no-port-forwarding ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDYU+u7FKdFoRq2BFyAVVznMhGmI4IiaqS3ewqpaaoSzMYoQ0UyUI7OOYHxDM1QI9E8ubX/j9+UJQFbGquT8cOO2pBqsjNQtumqzKgehzoDhjKomEC0KgqrCUjCA7JaLx5F+Lo1D8Vjco4K0CC1fjy6Lm8gbZxNC0D77xgyL2mmBbXO+LTm/CE+AmsHXh8OnLRzUVFdoOZYDJpCS7FlQixYhhd08nPjUqa9aAhpyURBwxLFojtdBFK/5lgOPlZBq0JSCn3lAPdrrZCA3zw6cs5AoPy3keOffbqoMs+/r9QqTPUrkfkt5AqPOXZaFkt3Xkaz53Tb6y696KiPr+2U1gSkuVnjxUUTXzukYGa6/r/CB6E7m8d70Sw1j3QGC1diohyEnYYuOWYv39GsOmfjjA0pTGwi3OiB5dWD1REfY6dJXbf2gamuULwy8q/C26fFNuTilg1JlBuxK8PzeWTuSCoeWdhXna1Z8BWQ4b55oV8puJeBiAl4NMgZ1k4vKGT4kBzMdhptYxHEt3IvnK7w/vzioLwBnhqORtiLheIsLCLKc2dWRDxbFq5540OiogqQMPYNOVboFxpbd5l0Z3mknULlmEXumgecg8UTwK4TE4eZkohhKEGG7EX65YqJOeQuKPSZjKC319Zs7h2fc6qS9tQO2M8/o6cQ2IYkTdVTyjz3OQ== gabriel@delta.local
2+

builder/bin/boot

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
#
3+
# This script is designed to be run inside the container
4+
#
5+
6+
# configure etcd
7+
export ETCD=${ETCD:-127.0.0.1:4001}
8+
export ETCD_PATH=${ETCD_PATH:-/deis/builder}
9+
export ETCD_TTL=${ETCD_TTL:-10}
10+
11+
# fail hard and fast even on pipelines
12+
set -eo pipefail
13+
14+
# configure service discovery
15+
export HOST=${HOST:-localhost}
16+
export PORT=${PORT:-22}
17+
export PROTO=${PROTO:-tcp}
18+
19+
# wait for etcd to be available
20+
until etcdctl -C $ETCD ls >/dev/null; do
21+
echo "waiting for etcd at $ETCD..."
22+
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
23+
done
24+
25+
# wait until etcd has discarded potentially stale values
26+
sleep $(($ETCD_TTL+1))
27+
28+
# seed initial service configuration if necessary
29+
$(dirname ${BASH_SOURCE[0]})/seed >/dev/null
30+
31+
# wait for confd to run once and install initial templates
32+
until confd -onetime -node $ETCD -config-file /app/confd.toml; do
33+
echo "waiting for confd to write initial templates..."
34+
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
35+
done
36+
37+
# spawn the service in the background
38+
$(dirname ${BASH_SOURCE[0]})/start &
39+
SERVICE_PID=$!
40+
41+
# smart shutdown on SIGINT and SIGTERM
42+
function on_exit() {
43+
rm -f /var/run/docker.pid
44+
kill -TERM $SERVICE_PID
45+
wait $SERVICE_PID 2>/dev/null
46+
}
47+
trap on_exit INT TERM EXIT
48+
49+
# spawn confd in the background to update services based on etcd changes
50+
confd -node $ETCD -config-file /app/confd.toml &
51+
CONFD_PID=$!
52+
53+
# wait for the service to become available
54+
sleep 1 && while [[ -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PORT\" && \$1 ~ \"$PROTO.?\"") ]] ; do sleep 1; done
55+
56+
# as long as the service remains up, keep publishing to etcd with a TTL
57+
$(dirname ${BASH_SOURCE[0]})/publish &
58+
59+
wait

builder/bin/entry

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# START jpetazzo/dind wrapper
5+
6+
# First, make sure that cgroups are mounted correctly.
7+
CGROUP=/sys/fs/cgroup
8+
9+
[ -d $CGROUP ] ||
10+
mkdir $CGROUP
11+
12+
mountpoint -q $CGROUP ||
13+
mount -n -t tmpfs -o uid=0,gid=0,mode=0755 cgroup $CGROUP || {
14+
echo "Could not make a tmpfs mount. Did you use -privileged?"
15+
exit 1
16+
}
17+
18+
if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security
19+
then
20+
mount -t securityfs none /sys/kernel/security || {
21+
echo "Could not mount /sys/kernel/security."
22+
echo "AppArmor detection and -privileged mode might break."
23+
}
24+
fi
25+
26+
# Mount the cgroup hierarchies exactly as they are in the parent system.
27+
for SUBSYS in $(cut -d: -f2 /proc/1/cgroup)
28+
do
29+
[ -d $CGROUP/$SUBSYS ] || mkdir $CGROUP/$SUBSYS
30+
mountpoint -q $CGROUP/$SUBSYS ||
31+
mount -n -t cgroup -o $SUBSYS cgroup $CGROUP/$SUBSYS
32+
33+
# The two following sections address a bug which manifests itself
34+
# by a cryptic "lxc-start: no ns_cgroup option specified" when
35+
# trying to start containers withina container.
36+
# The bug seems to appear when the cgroup hierarchies are not
37+
# mounted on the exact same directories in the host, and in the
38+
# container.
39+
40+
# Named, control-less cgroups are mounted with "-o name=foo"
41+
# (and appear as such under /proc/<pid>/cgroup) but are usually
42+
# mounted on a directory named "foo" (without the "name=" prefix).
43+
# Systemd and OpenRC (and possibly others) both create such a
44+
# cgroup. To avoid the aforementioned bug, we symlink "foo" to
45+
# "name=foo". This shouldn't have any adverse effect.
46+
echo $SUBSYS | grep -q ^name= && {
47+
NAME=$(echo $SUBSYS | sed s/^name=//)
48+
ln -s $SUBSYS $CGROUP/$NAME
49+
}
50+
51+
# Likewise, on at least one system, it has been reported that
52+
# systemd would mount the CPU and CPU accounting controllers
53+
# (respectively "cpu" and "cpuacct") with "-o cpuacct,cpu"
54+
# but on a directory called "cpu,cpuacct" (note the inversion
55+
# in the order of the groups). This tries to work around it.
56+
[ $SUBSYS = cpuacct,cpu ] && ln -s $SUBSYS $CGROUP/cpu,cpuacct
57+
done
58+
59+
# Note: as I write those lines, the LXC userland tools cannot setup
60+
# a "sub-container" properly if the "devices" cgroup is not in its
61+
# own hierarchy. Let's detect this and issue a warning.
62+
grep -q :devices: /proc/1/cgroup ||
63+
echo "WARNING: the 'devices' cgroup should be in its own hierarchy."
64+
grep -qw devices /proc/1/cgroup ||
65+
echo "WARNING: it looks like the 'devices' cgroup is not mounted."
66+
67+
# Now, close extraneous file descriptors.
68+
pushd /proc/self/fd >/dev/null
69+
for FD in *
70+
do
71+
case "$FD" in
72+
# Keep stdin/stdout/stderr
73+
[012])
74+
;;
75+
# Nuke everything else
76+
*)
77+
eval exec "$FD>&-"
78+
;;
79+
esac
80+
done
81+
popd >/dev/null
82+
83+
# END jpetazzo/dind wrapper
84+
85+
exec $@

builder/bin/publish

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# configure etcd
4+
ETCD=${ETCD:-127.0.0.1:4001}
5+
ETCD_PATH=${ETCD_PATH:-/deis/builder}
6+
ETCD_TTL=${ETCD_TTL:-10}
7+
8+
# while the port is listening, publish to etcd
9+
while [[ ! -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PORT\" && \$1 ~ \"$PROTO.?\"") ]] ; do
10+
etcdctl -C $ETCD set $ETCD_PATH/host $HOST --ttl $ETCD_TTL >/dev/null
11+
etcdctl -C $ETCD set $ETCD_PATH/port $PORT --ttl $ETCD_TTL >/dev/null
12+
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
13+
done
14+
15+
# if the loop quits, something went wrong
16+
exit 1

builder/bin/seed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# if the keyspace already exists, exit early
5+
etcdctl -C $ETCD ls $ETCD_PATH >/dev/null && exit 0
6+
7+
etcdctl -C $ETCD mkdir $ETCD_PATH/users || true

builder/bin/start

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# remove any pre-existing docker.sock
5+
rm -f /var/run/docker.sock
6+
7+
# spawn a docker daemon to run builds
8+
docker -d &
9+
10+
# wait for docker to start
11+
while [[ ! -e /var/run/docker.sock ]]; do
12+
sleep 1
13+
done
14+
15+
# pull required images
16+
docker pull deis/slugbuilder:latest
17+
docker pull deis/slugrunner:latest
18+
19+
# start an SSH daemon to process `git push` requests
20+
/usr/sbin/sshd -D -e

0 commit comments

Comments
 (0)