This includes two logically separate changes:
- on the host, try not to require sudo when running the build scripts
- namely when interacting with the docker daemon, this requires
the unix user on the host to be part of the `docker` group
- this solves part of https://github.com/spesmilo/electrum/issues/7602
- while running inside the docker containers, do not run as root
- this means that e.g. files created in mounted folders should
no longer be owned by root on the host
- there is some code duplication involved here - not sure
how it could be deduped.
31 lines
897 B
Docker
31 lines
897 B
Docker
FROM ubuntu:20.04@sha256:5747316366b8cc9e3021cd7286f42b2d6d81e3d743e2ab571f55bcd5df788cc8
|
|
|
|
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update -q && \
|
|
apt-get install -qy \
|
|
git \
|
|
gettext \
|
|
python3 \
|
|
python3-pip \
|
|
python3-setuptools \
|
|
python3-venv \
|
|
faketime \
|
|
&& \
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
apt-get autoremove -y && \
|
|
apt-get clean
|
|
|
|
# create new user to avoid using root; but with sudo access and no password for convenience.
|
|
ENV USER="user"
|
|
ENV HOME_DIR="/home/${USER}"
|
|
ENV WORK_DIR="${HOME_DIR}/wspace" \
|
|
PATH="${HOME_DIR}/.local/bin:${PATH}"
|
|
RUN useradd --create-home --shell /bin/bash ${USER}
|
|
RUN usermod -append --groups sudo ${USER}
|
|
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
|
WORKDIR ${WORK_DIR}
|
|
RUN chown --recursive ${USER} ${WORK_DIR}
|
|
USER ${USER}
|