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

Commit

Permalink
Dockerfiles improvements
Browse files Browse the repository at this point in the history
- investigates Docker image caching not fully leveraged, refs #160
- tries to keep image light in size, refs #161
  • Loading branch information
AndreMiras committed Oct 13, 2019
1 parent cf1300b commit a15c44d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ endif

system_dependencies_linux:
ifeq ($(OS), Ubuntu)
sudo apt update -qq > /dev/null && sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_LINUX)
sudo apt update -qq > /dev/null && sudo apt -qq install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_LINUX)
endif
system_dependencies_android:
ifeq ($(OS), Ubuntu)
sudo apt update -qq > /dev/null && sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_ANDROID)
sudo apt update -qq > /dev/null && sudo apt -qq install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES_ANDROID)
endif


Expand Down
33 changes: 18 additions & 15 deletions dockerfiles/Dockerfile-android
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FROM ubuntu:18.04

ENV USER="user"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}" \
ENV WORK_DIR="${HOME_DIR}/app" \
PATH="${HOME_DIR}/.local/bin:${PATH}"
ENV DOCKERFILES_VERSION="develop" \
DOCKERFILES_URL="https://raw.githubusercontent.com/AndreMiras/dockerfiles"
Expand All @@ -21,7 +21,8 @@ ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android"
# configure locale
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
locales && \
locale-gen en_US.UTF-8
locale-gen en_US.UTF-8 && \
rm -rf /var/lib/apt/lists/*
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"
Expand All @@ -32,25 +33,27 @@ ENV LANG="en_US.UTF-8" \
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
lsb-release \
make \
sudo
sudo && \
rm -rf /var/lib/apt/lists/*

# prepare non root env
RUN useradd --create-home --shell /bin/bash ${USER}
# with sudo access and no password
RUN usermod -append --groups sudo ${USER}
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# 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

USER ${USER}
WORKDIR ${WORK_DIR}

COPY Makefile ${WORK_DIR}
RUN sudo make system_dependencies_android
COPY Makefile /tmp/Makefile
RUN sudo make --file /tmp/Makefile system_dependencies_android && \
sudo rm /tmp/Makefile && \
sudo rm -rf /var/lib/apt/lists/*

# install buildozer and dependencies
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk
RUN make -f buildozer.mk
# enforces buildozer master (d483847) until next release
RUN pip3 install --upgrade https://github.com/kivy/buildozer/archive/d483847.zip
# install buildozer & dependencies and enforces buildozer master (d483847) until next release
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output /tmp/buildozer.mk && \
make --file /tmp/buildozer.mk && \
rm /tmp/buildozer.mk && \
pip3 install --no-cache-dir --upgrade https://github.com/kivy/buildozer/archive/d483847.zip

COPY . ${WORK_DIR}
ENTRYPOINT ["./dockerfiles/start.sh"]
26 changes: 15 additions & 11 deletions dockerfiles/Dockerfile-linux
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ FROM ubuntu:18.04

ENV USER="user"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}"
ENV WORK_DIR="${HOME_DIR}/app"

# configure locale
RUN apt update -qq > /dev/null && apt install --yes --no-install-recommends \
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
locales && \
locale-gen en_US.UTF-8
locale-gen en_US.UTF-8 && \
rm -rf /var/lib/apt/lists/*
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"
Expand All @@ -28,19 +29,22 @@ ENV LANG="en_US.UTF-8" \
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
lsb-release \
make \
sudo
sudo && \
rm -rf /var/lib/apt/lists/*

# prepare non root env
RUN useradd --create-home --shell /bin/bash ${USER}
# with sudo access and no password
RUN usermod -append --groups sudo ${USER}
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# 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

USER ${USER}
WORKDIR ${WORK_DIR}

COPY Makefile ${WORK_DIR}
RUN sudo make system_dependencies_linux
COPY Makefile /tmp/Makefile
RUN sudo make --file /tmp/Makefile system_dependencies_linux && \
sudo rm /tmp/Makefile && \
sudo rm -rf /var/lib/apt/lists/*

COPY . ${WORK_DIR}
# required by Kivy `App.user_data_dir`
RUN mkdir ~/.config
Expand Down

0 comments on commit a15c44d

Please sign in to comment.