Skip to content

Commit ec536af

Browse files
committed
[6.0-marshmallow] Add gosu; remove extra openjdk 8; refactor entrypoint script
1 parent 224c2e0 commit ec536af

File tree

3 files changed

+30
-44
lines changed

3 files changed

+30
-44
lines changed

Dockerfile

+19-27
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,47 @@
33
#
44
FROM ubuntu:14.04
55

6-
MAINTAINER Kyle Manna <[email protected]>
6+
LABEL maintainer "Kyle Manna <[email protected]>"
77

88
# /bin/sh points to Dash by default, reconfigure to use bash until Android
99
# build becomes POSIX compliant
1010
RUN echo "dash dash/sh boolean false" | debconf-set-selections && \
1111
dpkg-reconfigure -p critical dash
1212

1313
# Keep the dependency list as short as reasonable
14+
ENV GOSU_VERSION 1.10
1415
RUN apt-get update && \
1516
apt-get install -y bc bison bsdmainutils build-essential curl \
1617
flex g++-multilib gcc-multilib git gnupg gperf lib32ncurses5-dev \
1718
lib32readline-gplv2-dev lib32z1-dev libesd0-dev libncurses5-dev \
1819
libsdl1.2-dev libwxgtk2.8-dev libxml2-utils lzop \
1920
openjdk-7-jdk \
2021
pngcrush schedtool xsltproc zip zlib1g-dev && \
21-
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
22-
22+
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
23+
curl -Ls "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" | tee /usr/local/bin/gosu; \
24+
curl -Ls "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"| tee /usr/local/bin/gosu.asc \
25+
# verify the signature
26+
export GNUPGHOME="$(mktemp -d)"; \
27+
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
28+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
29+
rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
30+
chmod +x /usr/local/bin/gosu; \
31+
# verify it works
32+
gosu nobody true; \
33+
apt-get clean; apt-get purge --auto-remove ca-certificates; \
34+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2335
ADD https://commondatastorage.googleapis.com/git-repo-downloads/repo /usr/local/bin/
2436
RUN chmod 755 /usr/local/bin/*
2537

26-
# Install latest version of JDK
27-
# See http://source.android.com/source/initializing.html#setting-up-a-linux-build-environment
28-
WORKDIR /tmp
29-
RUN curl -O http://mirrors.kernel.org/ubuntu/pool/universe/o/openjdk-8/openjdk-8-jre-headless_8u45-b14-1_amd64.deb && \
30-
curl -O http://mirrors.kernel.org/ubuntu/pool/universe/o/openjdk-8/openjdk-8-jre_8u45-b14-1_amd64.deb && \
31-
curl -O http://mirrors.kernel.org/ubuntu/pool/universe/o/openjdk-8/openjdk-8-jdk_8u45-b14-1_amd64.deb && \
32-
sum=`shasum ./openjdk-8-jre-headless_8u45-b14-1_amd64.deb | awk '{ print $1 }'` && \
33-
[ $sum == "e10d79f7fd1b3d011d9a4910bc3e96c3090f3306" ] || \
34-
( echo "Hash mismatch. Problem downloading openjdk-8-jre-headless" ; exit 1; ) && \
35-
sum=`shasum ./openjdk-8-jre_8u45-b14-1_amd64.deb | awk '{ print $1 }'` && \
36-
[ $sum == "1e083bb952fc97ab33cd46f68e82688d2b8acc34" ] || \
37-
( echo "Hash mismatch. Problem downloading openjdk-8-jre" ; exit 1; ) && \
38-
sum=`shasum ./openjdk-8-jdk_8u45-b14-1_amd64.deb | awk '{ print $1 }'` && \
39-
[ $sum == "772e904961a2a5c7d2d129bdbcfd5c16a0fab4bf" ] || \
40-
( echo "Hash mismatch. Problem downloading openjdk-8-jdk" ; exit 1; ) && \
41-
dpkg -i *.deb && \
42-
apt-get -f install && \
43-
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
44-
4538
# All builds will be done by user aosp
46-
COPY gitconfig /root/.gitconfig
47-
COPY ssh_config /root/.ssh/config
39+
COPY gitconfig /home/aosp/.gitconfig
40+
COPY ssh_config /home/aosp/.ssh/config
4841

4942
# The persistent data will be in these two directories, everything else is
5043
# considered to be ephemeral
5144
VOLUME ["/tmp/ccache", "/aosp"]
5245

5346
# Work in the build directory, repo is expected to be init'd here
5447
WORKDIR /aosp
55-
56-
COPY utils/docker_entrypoint.sh /root/docker_entrypoint.sh
57-
ENTRYPOINT ["/root/docker_entrypoint.sh"]
48+
COPY utils/docker_entrypoint.sh /docker_entrypoint.sh
49+
ENTRYPOINT ["/docker_entrypoint.sh"]

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ services:
66
volumes:
77
- ~/aosp/ccache:/tmp/ccache
88
- ~/aosp:/aosp
9-
- ~/.gitconfig:/root/.gitconfig
9+
- ~/.gitconfig:/home/aosp/.gitconfig
10+
# uncomment if you want this
11+
#- ~/.ssh/config:/home/.ssh/config

utils/docker_entrypoint.sh

+8-16
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,23 @@ export CCACHE_DIR=/tmp/ccache
2222
export USE_CCACHE=1
2323

2424
msg="docker_entrypoint: Creating user UID/GID [$USER_ID/$GROUP_ID]" && echo $msg
25-
groupadd -g $GROUP_ID -r aosp && \
26-
useradd -u $USER_ID --create-home -r -g aosp aosp
25+
groupadd -g $GROUP_ID -r aosp ; useradd -u $USER_ID -r -g aosp aosp
2726
echo "$msg - done"
2827

29-
msg="docker_entrypoint: Copying .gitconfig and .ssh/config to new user home" && echo $msg
30-
cp /root/.gitconfig /home/aosp/.gitconfig && \
31-
chown aosp:aosp /home/aosp/.gitconfig && \
32-
mkdir -p /home/aosp/.ssh && \
33-
cp /root/.ssh/config /home/aosp/.ssh/config && \
34-
chown aosp:aosp -R /home/aosp/.ssh &&
35-
echo "$msg - done"
3628

37-
msg="docker_entrypoint: Creating /tmp/ccache and /aosp directory" && echo $msg
38-
mkdir -p /tmp/ccache /aosp
39-
chown aosp:aosp /tmp/ccache /aosp
29+
msg="docker_entrypoint: Changing ownership of /tmp/ccache and /aosp..." && echo $msg
30+
chown -R aosp:aosp /tmp/ccache /aosp
4031
echo "$msg - done"
4132

33+
msg="docker_entrypoint: Changing ownership of gitconfig and .ssh/config..." && echo $msg
34+
chown -R aosp:aosp /home/aosp/.gitconfig /home/aosp/.ssh/
35+
echo "$msg - done"
4236
echo ""
4337

4438
# Default to 'bash' if no arguments are provided
4539
args="$@"
46-
if [ -z "$args" ]; then
47-
args="bash"
48-
fi
40+
[ -z "$args" ] || args="bash"
4941

5042
# Execute command as `aosp` user
5143
export HOME=/home/aosp
52-
exec sudo -u aosp $args
44+
exec gosu aosp $args

0 commit comments

Comments
 (0)