Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Makefile and Dockerfile optimizations, fixes #161
Browse files Browse the repository at this point in the history
- reduces the number of dependencies on both images
- optimizes layers
- simplifies .travis.yml
  • Loading branch information
AndreMiras committed Oct 30, 2019
1 parent 8e31da5 commit 4f2de1f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 70 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ services:
- xvfb

env:
global:
- secure: Lg6sE2VfTO4SeBi0eI17alK0/Bd+2YNpXL41szC1qztuj3r0HBOHuU27bBTGiUQ2fCMI9hTPdFNliKJaFbn4SNckCVIGyslkPu+gB6qMUzkiY1Mzhxos1q3FMxESsFeM1wYArvIyrsxhtFlAHk8xeHb7h/jbkFoY4gi3ubXdKVolbGFzeQDv7D18MTJ1/e4LaHG9h7nLrs41D8I8CMECD+pE4y2kMbKUqbIHVXF3IggQHoq15bAppHUjM+ofI7jxpXf+qwlnIQYDnRgKisuCb7hI9EmJ1gMKX4DKo/r1KHsHBaQoS9//SlYZ8+usleCYw/y/40w7ZobeILxUKyEpcxyDeYFGAeP7iFln5KVpqpirpdpraG0F9e2mktRNWKqiZcNWuFftYayHYx12ON7u9cu5gLVG6m7Wfwk6b6+fRQM3OECx0+w4d+6ANPLEeFgGf4+OwB5m8AIwJMLXvNrh/BweLD91lFfB95r3ByW30aHajD6YsomL68vm36imXunk0bxvwfzK09Lux3xgSpMlj+KTRkfkPD+08ufMZoiGL8nXB6pqRdhL1SZiZdo09psAJCCAWyneaMNZUVN/hp6fdCmVi4e0J+TZpRJSGP8X0MFY4crtNrcfgDxeXuTAbDh1ln+/Tn02BDU7/1dbO+vTmD3wRss7CruZ9N3KnpnGYLU=
matrix:
- TAG=linux
- TAG=android
Expand Down
49 changes: 18 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,31 @@ DOCKER_IMAGE_LINUX=andremiras/etherollapp-linux
DOCKER_IMAGE_ANDROID=andremiras/etherollapp-android
DOCKER_VOLUME=/tmp/.X11-unix:/tmp/.X11-unix
SYSTEM_DEPENDENCIES_BASE= \
git \
libffi-dev \
libpython$(PYTHON_VERSION)-dev \
pkg-config \
python$(PYTHON_VERSION)
python$(PYTHON_VERSION)
SYSTEM_DEPENDENCIES_LINUX= \
build-essential \
libgmp3-dev \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libssl-dev \
tox \
virtualenv \
xclip \
xsel \
libzbar-dev
build-essential \
libgl1 \
libzbar0 \
python$(PYTHON_MAJOR_VERSION)-virtualenv \
tox
SYSTEM_DEPENDENCIES_ANDROID= \
autoconf \
autogen \
automake \
bsdtar \
ca-certificates \
cmake \
curl \
gettext \
libffi-dev \
libltdl-dev \
git \
libtool \
openjdk-8-jdk \
python2.7 \
python3-pip \
python3-setuptools \
openjdk-8-jdk-headless \
patch \
pkg-config \
python$(PYTHON_MAJOR_VERSION)-pip \
python$(PYTHON_MAJOR_VERSION)-setuptools \
unzip \
xz-utils \
zip \
zlib1g-dev
zlib1g-dev \
zip
ifndef CI
DOCKER_DEVICE=--device=/dev/video0:/dev/video0
endif
Expand Down Expand Up @@ -114,7 +102,6 @@ release/upload:
$(TWINE) upload dist/*

clean:
py3clean .
rm -rf .pytest_cache/
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type d -name "*.egg-info" -exec rm -r {} +
Expand Down Expand Up @@ -147,13 +134,13 @@ docker/push/android:
docker/push: docker/push/linux docker/push/android

docker/run/test/linux:
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) $(DOCKER_IMAGE_LINUX) 'make test'
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) -it --rm $(DOCKER_IMAGE_LINUX) make test

docker/run/test/android:
docker run --env-file dockerfiles/env.list $(DOCKER_IMAGE_ANDROID) 'make buildozer/android/debug'
docker run --env-file dockerfiles/env.list $(DOCKER_IMAGE_ANDROID) make buildozer/android/debug

docker/run/app:
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) $(DOCKER_IMAGE_LINUX) 'make run'
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) -it --rm $(DOCKER_IMAGE_LINUX) make run

docker/run/shell/linux:
docker run --env-file dockerfiles/env.list -v $(DOCKER_VOLUME) $(DOCKER_DEVICE) -it --rm $(DOCKER_IMAGE_LINUX)
Expand Down
20 changes: 8 additions & 12 deletions dockerfiles/Dockerfile-android
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# Build with:
# docker build --tag=andremiras/etherollapp-android --file=dockerfiles/Dockerfile-android .
# Run with:
# docker run andremiras/etherollapp-android /bin/sh -c 'buildozer android debug'
# Or using the entry point shortcut:
# docker run andremiras/etherollapp-android 'buildozer android debug'
# docker run -it --rm andremiras/etherollapp-android buildozer android debug
# Or for interactive shell:
# docker run -it --rm andremiras/etherollapp-android
FROM ubuntu:18.04
Expand All @@ -24,33 +22,31 @@ ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"

# install build dependencies (required to successfully build the project)
# install minimal system dependencies
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
lsb-release \
make \
sudo && \
rm -rf /var/lib/apt/lists/*

# prepare non root env, with sudo access and no password
RUN useradd --create-home --home-dir ${HOME_DIR} --shell /bin/bash ${USER} && \
usermod -append --groups sudo ${USER} && \
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
mkdir ${WORK_DIR} && \
chown ${USER}:${USER} -R ${WORK_DIR}

USER ${USER}
WORKDIR ${WORK_DIR}

# install system dependencies
# install buildozer & dependencies and enforces buildozer master (d483847) until next release
COPY Makefile /tmp/Makefile
RUN sudo make --file /tmp/Makefile system_dependencies/android && \
sudo rm /tmp/Makefile && \
sudo rm -rf /var/lib/apt/lists/* && \
mkdir ${WORK_DIR}

# install buildozer & dependencies and enforces buildozer master (d483847) until next release
RUN pip3 install --no-cache-dir --upgrade \
pip3 install --no-cache-dir --upgrade \
Cython==0.28.6 \
https://github.com/kivy/buildozer/archive/d483847.zip && \
rm -rf ~/.cache/

WORKDIR ${WORK_DIR}
COPY . ${WORK_DIR}
ENTRYPOINT ["./dockerfiles/start.sh"]
27 changes: 12 additions & 15 deletions dockerfiles/Dockerfile-linux
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
# Build with:
# docker build --tag=andremiras/etherollapp-linux --file=dockerfiles/Dockerfile-linux .
# Run with:
# docker run andremiras/etherollapp-linux /bin/sh -c 'make test'
# Or using the entry point shortcut:
# docker run andremiras/etherollapp-linux 'make test'
# docker run -it --rm andremiras/etherollapp-linux make test
# Or for interactive shell:
# docker run -it --rm andremiras/etherollapp-linux
# For running UI:
# xhost +"local:docker@"
# docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix andremiras/etherollapp-linux 'make uitest'
# docker run -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --it -rm andremiras/etherollapp-linux make uitest
FROM ubuntu:18.04

ENV USER="user"
Expand All @@ -25,29 +23,28 @@ ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"

# install system dependencies
# install minimal system dependencies
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
lsb-release \
make \
sudo && \
rm -rf /var/lib/apt/lists/*

# prepare non root env, with sudo access and no password
RUN useradd --create-home --home-dir ${HOME_DIR} --shell /bin/bash ${USER} && \
usermod -append --groups sudo ${USER} && \
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
mkdir ${WORK_DIR} && \
chown ${USER}:${USER} -R ${WORK_DIR}

USER ${USER}
WORKDIR ${WORK_DIR}

# install system dependencies
COPY Makefile /tmp/Makefile
RUN sudo make --file /tmp/Makefile system_dependencies/linux && \
sudo rm /tmp/Makefile && \
COPY Makefile requirements.txt ${WORK_DIR}/
RUN sudo make system_dependencies/linux && \
make virtualenv && \
sudo rm ${WORK_DIR}/requirements.txt ${WORK_DIR}/Makefile && \
sudo rm -rf /var/lib/apt/lists/* && \
mkdir ${WORK_DIR}
mkdir ~/.config

WORKDIR ${WORK_DIR}
COPY . ${WORK_DIR}
# required by Kivy `App.user_data_dir`
RUN mkdir ~/.config
ENTRYPOINT ["./dockerfiles/start.sh"]
10 changes: 0 additions & 10 deletions dockerfiles/start.sh

This file was deleted.

0 comments on commit 4f2de1f

Please sign in to comment.