mirror of https://github.com/ArduPilot/ardupilot
Dockerfile: improve docker env to be runnable noninteractively
This commit is contained in:
parent
99ef5f5957
commit
3969ae411b
36
Dockerfile
36
Dockerfile
|
@ -2,36 +2,48 @@ FROM ubuntu:20.04
|
||||||
WORKDIR /ardupilot
|
WORKDIR /ardupilot
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
RUN useradd -U -m ardupilot && \
|
ARG USER_NAME=ardupilot
|
||||||
usermod -G users ardupilot
|
ARG USER_UID=1000
|
||||||
|
ARG USER_GID=1000
|
||||||
|
RUN groupadd ${USER_NAME} --gid ${USER_GID}\
|
||||||
|
&& useradd -l -m ${USER_NAME} -u ${USER_UID} -g ${USER_GID} -s /bin/bash
|
||||||
|
|
||||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
lsb-release \
|
lsb-release \
|
||||||
sudo \
|
sudo \
|
||||||
bash-completion \
|
tzdata \
|
||||||
software-properties-common
|
bash-completion
|
||||||
|
|
||||||
COPY Tools/environment_install/install-prereqs-ubuntu.sh /ardupilot/Tools/environment_install/
|
COPY Tools/environment_install/install-prereqs-ubuntu.sh /ardupilot/Tools/environment_install/
|
||||||
COPY Tools/completion /ardupilot/Tools/completion/
|
COPY Tools/completion /ardupilot/Tools/completion/
|
||||||
|
|
||||||
# Create non root user for pip
|
# Create non root user for pip
|
||||||
ENV USER=ardupilot
|
ENV USER=${USER_NAME}
|
||||||
|
|
||||||
RUN echo "ardupilot ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ardupilot
|
RUN echo "ardupilot ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USER_NAME}
|
||||||
RUN chmod 0440 /etc/sudoers.d/ardupilot
|
RUN chmod 0440 /etc/sudoers.d/${USER_NAME}
|
||||||
|
|
||||||
RUN chown -R ardupilot:ardupilot /ardupilot
|
RUN chown -R ${USER_NAME}:${USER_NAME} /${USER_NAME}
|
||||||
|
|
||||||
USER ardupilot
|
USER ${USER_NAME}
|
||||||
|
|
||||||
ENV SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
|
ENV SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
|
||||||
RUN Tools/environment_install/install-prereqs-ubuntu.sh -y
|
RUN Tools/environment_install/install-prereqs-ubuntu.sh -y
|
||||||
|
|
||||||
# add waf alias to ardupilot waf to .bashrc
|
# add waf alias to ardupilot waf to .bashrc
|
||||||
RUN echo "alias waf=\"/ardupilot/waf\"" >> ~/.bashrc
|
RUN echo "alias waf=\"/${USER_NAME}/waf\"" >> ~/ardupilot_entrypoint.sh
|
||||||
|
|
||||||
# Check that local/bin are in PATH for pip --user installed package
|
# Check that local/bin are in PATH for pip --user installed package
|
||||||
RUN echo "if [ -d \"\$HOME/.local/bin\" ] ; then\nPATH=\"\$HOME/.local/bin:\$PATH\"\nfi" >> ~/.bashrc
|
RUN echo "if [ -d \"\$HOME/.local/bin\" ] ; then\nPATH=\"\$HOME/.local/bin:\$PATH\"\nfi" >> ~/ardupilot_entrypoint.sh
|
||||||
|
|
||||||
|
# Create entrypoint as docker cannot do shell substitution correctly
|
||||||
|
RUN export ARDUPILOT_ENTRYPOINT="/home/${USER_NAME}/ardupilot_entrypoint.sh" \
|
||||||
|
&& echo "#!/bin/bash" > $ARDUPILOT_ENTRYPOINT \
|
||||||
|
&& echo "set -e" >> $ARDUPILOT_ENTRYPOINT \
|
||||||
|
&& echo "source /home/${USER_NAME}/.ardupilot_env" >> $ARDUPILOT_ENTRYPOINT \
|
||||||
|
&& echo 'exec "$@"' >> $ARDUPILOT_ENTRYPOINT \
|
||||||
|
&& chmod +x $ARDUPILOT_ENTRYPOINT \
|
||||||
|
&& sudo mv $ARDUPILOT_ENTRYPOINT /ardupilot_entrypoint.sh
|
||||||
|
|
||||||
# Set the buildlogs directory into /tmp as other directory aren't accessible
|
# Set the buildlogs directory into /tmp as other directory aren't accessible
|
||||||
ENV BUILDLOGS=/tmp/buildlogs
|
ENV BUILDLOGS=/tmp/buildlogs
|
||||||
|
@ -41,3 +53,5 @@ RUN sudo apt-get clean \
|
||||||
&& sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
&& sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
ENV CCACHE_MAXSIZE=1G
|
ENV CCACHE_MAXSIZE=1G
|
||||||
|
ENTRYPOINT ["/ardupilot_entrypoint.sh"]
|
||||||
|
CMD ["bash"]
|
||||||
|
|
Loading…
Reference in New Issue