1
0
mirror of https://github.com/stucki/docker-lineageos synced 2024-12-19 17:12:29 -05:00

Merge pull request #39 from bebehei/misc-improvements

Various improvements
This commit is contained in:
Michael Stucki 2017-08-05 22:59:35 +02:00 committed by GitHub
commit c7dc2d69ca
4 changed files with 29 additions and 25 deletions

View File

@ -3,6 +3,16 @@
FROM ubuntu:16.04
MAINTAINER Michael Stucki <michael@stucki.io>
ENV \
# ccache specifics
CCACHE_SIZE=50G \
CCACHE_DIR=/srv/ccache \
USE_CCACHE=1 \
CCACHE_COMPRESS=1 \
# Extra include PATH, it may not include /usr/local/(s)bin on some systems
PATH=$PATH:/usr/local/bin/
RUN sed -i 's/main$/main universe/' /etc/apt/sources.list \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
@ -64,9 +74,8 @@ RUN \
useradd --gid $hostgid --uid $hostuid --non-unique build && \
rsync -a /etc/skel/ /home/build/
RUN mkdir /home/build/bin
RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /home/build/bin/repo
RUN chmod a+x /home/build/bin/repo
RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo \
&& chmod a+x /usr/local/bin/repo
# Add sudo permission
RUN echo "build ALL=NOPASSWD: ALL" > /etc/sudoers.d/build
@ -77,14 +86,10 @@ RUN chmod a+x /home/build/startup.sh
# Fix ownership
RUN chown -R build:build /home/build
# Set global variables
ADD android-env-vars.sh /etc/android-env-vars.sh
RUN echo "source /etc/android-env-vars.sh" >> /etc/bash.bashrc
VOLUME /home/build/android
VOLUME /srv/ccache
CMD /home/build/startup.sh
USER build
WORKDIR /home/build/android
CMD /home/build/startup.sh

View File

@ -1,4 +0,0 @@
export PATH=/home/build/bin:$PATH
export USE_CCACHE=1
export CCACHE_DIR=/srv/ccache
export CCACHE_COMPRESS=1

19
run.sh
View File

@ -34,16 +34,18 @@ while [[ $# > 0 ]]; do
done
# Create shared folders
# Although Docker would create non-existing directories on the fly,
# we need to have them owned by the user (and not root), to be able
# to write in them, which is a necessity for startup.sh
mkdir -p $SOURCE
mkdir -p $CCACHE
command -v docker >/dev/null \
|| { echo "command 'docker' not found."; exit 1; }
# Build image if needed
IMAGE_EXISTS=$(docker images $REPOSITORY)
if [ $? -ne 0 ]; then
echo "docker command not found"
exit $?
elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then
echo "Building Docker image $REPOSITORY:$TAG..."
if [[ $FORCE_BUILD = 1 ]] || ! docker inspect $REPOSITORY:$TAG &>/dev/null; then
docker build \
--pull \
-t $REPOSITORY:$TAG \
@ -52,9 +54,8 @@ elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then
.
# After successful build, delete existing containers
IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null) || true
if [[ -n $IS_EXISTING ]]; then
docker rm $CONTAINER
if docker inspect $CONTAINER &>/dev/null; then
docker rm $CONTAINER >/dev/null
fi
fi

View File

@ -1,12 +1,14 @@
#!/bin/sh
# Initialize ccache if needed
if [ ! -f /srv/ccache/ccache.conf ]; then
if [ ! -f ${CCACHE_DIR}/ccache.conf ]; then
echo "Initializing ccache in /srv/ccache..."
CCACHE_DIR=/srv/ccache ccache -M 50G
ccache -M ${CCACHE_SIZE}
fi
export USER="build"
# in Docker, the USER variable is unset by default
# but some programs (like jack toolchain) rely on it
export USER="$(whoami)"
# Launch screen session
screen -s /bin/bash