Skip to content

Commit 3c64e58

Browse files
committed
Merge pull request #3664 from aledbf/alpinelinux
ref(*): use alpine as replacement of ubuntu-debootstrap as base image
2 parents 575f68d + fc74ff3 commit 3c64e58

45 files changed

Lines changed: 202 additions & 192 deletions

Some content is hidden

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

builder/image/Dockerfile

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
FROM ubuntu-debootstrap:14.04
2-
3-
ENV DEBIAN_FRONTEND noninteractive
1+
FROM alpine:3.1
42

53
# install common packages
6-
RUN apt-get update && apt-get install -y curl net-tools sudo
4+
RUN apk add --update-cache curl bash sudo && rm -rf /var/cache/apk/*
75

86
# install etcdctl
97
RUN curl -sSL -o /usr/local/bin/etcdctl https://s3-us-west-2.amazonaws.com/opdemand/etcdctl-v0.4.6 \
@@ -13,28 +11,32 @@ RUN curl -sSL -o /usr/local/bin/etcdctl https://s3-us-west-2.amazonaws.com/opdem
1311
RUN curl -sSL -o /usr/local/bin/confd https://github.com/kelseyhightower/confd/releases/download/v0.9.0/confd-0.9.0-linux-amd64 \
1412
&& chmod +x /usr/local/bin/confd
1513

16-
# install docker-in-docker
17-
RUN echo "deb http://get.docker.com/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
18-
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
14+
RUN apk add --update-cache \
15+
coreutils \
16+
device-mapper \
17+
e2fsprogs \
18+
git \
19+
iptables \
20+
libudev \
21+
lxc \
22+
openssh \
23+
udev \
24+
util-linux \
25+
xz \
26+
&& rm -rf /var/cache/apk/*
1927

20-
# install builder, docker, and hook dependencies
21-
RUN apt-get update && apt-get install -yq \
22-
openssh-server git \
23-
aufs-tools iptables lxc \
24-
lxc-docker-1.5.0
28+
# the docker package in alpine disables aufs and devicemapper
29+
RUN curl -sSL https://get.docker.com/builds/Linux/x86_64/docker-1.5.0 -o /usr/bin/docker && \
30+
chmod +x /usr/bin/docker
2531

2632
# configure ssh server
27-
RUN rm /etc/ssh/ssh_host_*
28-
RUN dpkg-reconfigure openssh-server
29-
RUN mkdir -p /var/run/sshd
30-
31-
# configure locale
32-
RUN echo LANG="en_US.UTF-8" > /etc/default/locale && dpkg-reconfigure locales
33+
RUN mkdir -p /var/run/sshd && rm -rf /etc/ssh/ssh_host*
34+
RUN /usr/bin/ssh-keygen -A
3335

3436
# install git and configure gituser
3537
ENV GITHOME /home/git
3638
ENV GITUSER git
37-
RUN useradd -d $GITHOME $GITUSER
39+
RUN adduser -D -h $GITHOME $GITUSER
3840
RUN mkdir -p $GITHOME/.ssh && chown git:git $GITHOME/.ssh
3941
RUN chown -R $GITUSER:$GITUSER $GITHOME
4042

@@ -46,12 +48,14 @@ WORKDIR /app
4648
ENTRYPOINT ["/app/bin/entry"]
4749
CMD ["/app/bin/boot"]
4850
EXPOSE 22
49-
RUN addgroup --quiet --gid 2000 slug && useradd slug --uid=2000 --gid=2000
51+
RUN addgroup -g 2000 slug && adduser -D -u 2000 -G slug slug
5052

5153
# $GITUSER is added to docker group to use docker without sudo and to slug
5254
# group in order to share resources with the slug user
53-
RUN usermod -a -G docker $GITUSER
54-
RUN usermod -a -G slug $GITUSER
55+
RUN addgroup -S docker
56+
RUN addgroup $GITUSER docker
57+
RUN addgroup $GITUSER slug
58+
RUN passwd -u git
5559

5660
ADD templates/shim.dockerfile /home/git/
5761
ADD etc /etc

builder/image/bin/apparmor_parser

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
exit 0;

builder/image/bin/boot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ if [[ "$fstype" == "overlay" ]]; then
6060
DRIVER_OVERRIDE="--storage-driver=overlay"
6161
fi
6262

63+
# cheat
64+
cp /app/bin/apparmor_parser /sbin/apparmor_parser
65+
6366
# spawn a docker daemon to run builds
6467
docker -d --bip=172.19.42.1/16 $DRIVER_OVERRIDE --insecure-registry 10.0.0.0/8 --insecure-registry 172.16.0.0/12 --insecure-registry 192.168.0.0/16 --insecure-registry 100.64.0.0/10 &
6568
DOCKER_PID=$!

builder/image/etc/ssh/sshd_config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ PrintLastLog yes
2626
TCPKeepAlive yes
2727
#AcceptEnv LANG LC_*
2828
Subsystem sftp /usr/lib/openssh/sftp-server
29-
UsePAM yes
3029
UseDNS no

builder/image/templates/builder

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ TMP_IMAGE="{{ getv "/deis/registry/host" }}:{{ getv "/deis/registry/port" }}/$IM
6161
# create app directories
6262
mkdir -p $BUILD_DIR $CACHE_DIR
6363
# create temporary directory inside the build dir for this push
64-
TMP_DIR=$(mktemp -d --tmpdir=$BUILD_DIR)
64+
TMP_DIR=$(mktemp -d -p $BUILD_DIR)
6565

6666
cd $REPO_DIR
6767
git archive $GIT_SHA | tar -xmC $TMP_DIR
@@ -108,7 +108,7 @@ if [ ! -f Dockerfile ]; then
108108
# TMP_DIR is created using mktemp, which sets permissions to 700. Since
109109
# we share this with the slug group, the slug group needs to be able to
110110
# work with it.
111-
chmod g+rwx $TMP_DIR
111+
chmod g+rwx $TMP_DIR $CACHE_DIR
112112

113113
BUILD_OPTS+=' deis/slugbuilder'
114114

builder/image/templates/gitreceive

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eo pipefail
55
# "remote: Updated branch 'master' of 'repo'. Deploying to dev." becomes
66
# "Updated branch 'master' of 'repo'. Deploying to dev."
77
strip_remote_prefix() {
8-
sed -u "s/^/"$'\e[1G'"/"
8+
stdbuf -i0 -o0 -e0 sed "s/^/"$'\e[1G'"/"
99
}
1010

1111
GITUSER=${GITUSER:-git}

cache/Dockerfile

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

cache/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
99
COMPONENT = $(notdir $(repo_path))
1010
IMAGE = $(IMAGE_PREFIX)$(COMPONENT):$(BUILD_TAG)
1111
DEV_IMAGE = $(DEV_REGISTRY)/$(IMAGE)
12-
BUILD_IMAGE = $(COMPONENT)-build
1312
BINARY_DEST_DIR = image/bin
1413

1514
build: check-docker
1615
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -installsuffix cgo -ldflags '-s' -o $(BINARY_DEST_DIR)/boot main.go || exit 1
1716
$(call check-static-binary,$(BINARY_DEST_DIR)/boot)
18-
docker build -t $(BUILD_IMAGE) .
19-
docker cp `docker run -d $(BUILD_IMAGE)`:/usr/local/bin/redis-server $(BINARY_DEST_DIR)/
2017
docker build -t $(IMAGE) image
2118

2219
clean: check-docker check-registry

cache/image/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM ubuntu-debootstrap:14.04
1+
FROM alpine:3.1
2+
3+
RUN apk add --update-cache redis && rm -rf /var/cache/apk/*
24

35
ADD . /app
46
WORKDIR /app

cache/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func replaceMaxmemoryInConfig(maxmemory string) {
6969
}
7070

7171
func launchRedis() {
72-
cmd := exec.Command("/app/bin/redis-server", redisConf)
72+
cmd := exec.Command("redis-server", redisConf)
7373
cmd.Stdout = os.Stdout
7474
cmd.Stderr = os.Stderr
7575

0 commit comments

Comments
 (0)