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:
commit
c7dc2d69ca
23
Dockerfile
23
Dockerfile
@ -3,6 +3,16 @@
|
|||||||
FROM ubuntu:16.04
|
FROM ubuntu:16.04
|
||||||
MAINTAINER Michael Stucki <michael@stucki.io>
|
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 \
|
RUN sed -i 's/main$/main universe/' /etc/apt/sources.list \
|
||||||
&& export DEBIAN_FRONTEND=noninteractive \
|
&& export DEBIAN_FRONTEND=noninteractive \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
@ -64,9 +74,8 @@ RUN \
|
|||||||
useradd --gid $hostgid --uid $hostuid --non-unique build && \
|
useradd --gid $hostgid --uid $hostuid --non-unique build && \
|
||||||
rsync -a /etc/skel/ /home/build/
|
rsync -a /etc/skel/ /home/build/
|
||||||
|
|
||||||
RUN mkdir /home/build/bin
|
RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo \
|
||||||
RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /home/build/bin/repo
|
&& chmod a+x /usr/local/bin/repo
|
||||||
RUN chmod a+x /home/build/bin/repo
|
|
||||||
|
|
||||||
# Add sudo permission
|
# Add sudo permission
|
||||||
RUN echo "build ALL=NOPASSWD: ALL" > /etc/sudoers.d/build
|
RUN echo "build ALL=NOPASSWD: ALL" > /etc/sudoers.d/build
|
||||||
@ -77,14 +86,10 @@ RUN chmod a+x /home/build/startup.sh
|
|||||||
# Fix ownership
|
# Fix ownership
|
||||||
RUN chown -R build:build /home/build
|
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 /home/build/android
|
||||||
VOLUME /srv/ccache
|
VOLUME /srv/ccache
|
||||||
|
|
||||||
CMD /home/build/startup.sh
|
|
||||||
|
|
||||||
USER build
|
USER build
|
||||||
WORKDIR /home/build/android
|
WORKDIR /home/build/android
|
||||||
|
|
||||||
|
CMD /home/build/startup.sh
|
||||||
|
@ -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
19
run.sh
@ -34,16 +34,18 @@ while [[ $# > 0 ]]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Create shared folders
|
# 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 $SOURCE
|
||||||
mkdir -p $CCACHE
|
mkdir -p $CCACHE
|
||||||
|
|
||||||
|
command -v docker >/dev/null \
|
||||||
|
|| { echo "command 'docker' not found."; exit 1; }
|
||||||
|
|
||||||
# Build image if needed
|
# Build image if needed
|
||||||
IMAGE_EXISTS=$(docker images $REPOSITORY)
|
if [[ $FORCE_BUILD = 1 ]] || ! docker inspect $REPOSITORY:$TAG &>/dev/null; then
|
||||||
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..."
|
|
||||||
docker build \
|
docker build \
|
||||||
--pull \
|
--pull \
|
||||||
-t $REPOSITORY:$TAG \
|
-t $REPOSITORY:$TAG \
|
||||||
@ -52,9 +54,8 @@ elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then
|
|||||||
.
|
.
|
||||||
|
|
||||||
# After successful build, delete existing containers
|
# After successful build, delete existing containers
|
||||||
IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null) || true
|
if docker inspect $CONTAINER &>/dev/null; then
|
||||||
if [[ -n $IS_EXISTING ]]; then
|
docker rm $CONTAINER >/dev/null
|
||||||
docker rm $CONTAINER
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Initialize ccache if needed
|
# Initialize ccache if needed
|
||||||
if [ ! -f /srv/ccache/ccache.conf ]; then
|
if [ ! -f ${CCACHE_DIR}/ccache.conf ]; then
|
||||||
echo "Initializing ccache in /srv/ccache..."
|
echo "Initializing ccache in /srv/ccache..."
|
||||||
CCACHE_DIR=/srv/ccache ccache -M 50G
|
ccache -M ${CCACHE_SIZE}
|
||||||
fi
|
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
|
# Launch screen session
|
||||||
screen -s /bin/bash
|
screen -s /bin/bash
|
||||||
|
Loading…
Reference in New Issue
Block a user