-
Notifications
You must be signed in to change notification settings - Fork 17.5k
/
Dockerfile
75 lines (60 loc) · 2.6 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
ARG BASE_IMAGE="ubuntu"
ARG TAG="22.04"
FROM ${BASE_IMAGE}:${TAG}
WORKDIR /ardupilot
ARG DEBIAN_FRONTEND=noninteractive
ARG USER_NAME=ardupilot
ARG USER_UID=1000
ARG USER_GID=1000
ARG SKIP_AP_EXT_ENV=0
ARG SKIP_AP_GRAPHIC_ENV=1
ARG SKIP_AP_COV_ENV=1
ARG SKIP_AP_GIT_CHECK=1
ARG DO_AP_STM_ENV=1
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 \
lsb-release \
sudo \
tzdata \
git \
default-jre \
bash-completion
COPY Tools/environment_install/install-prereqs-ubuntu.sh /ardupilot/Tools/environment_install/
COPY Tools/completion /ardupilot/Tools/completion/
# Create non root user for pip
RUN echo "ardupilot ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USER_NAME}
RUN chmod 0440 /etc/sudoers.d/${USER_NAME}
RUN chown -R ${USER_NAME}:${USER_NAME} /${USER_NAME}
USER ${USER_NAME}
RUN SKIP_AP_EXT_ENV=$SKIP_AP_EXT_ENV SKIP_AP_GRAPHIC_ENV=$SKIP_AP_GRAPHIC_ENV SKIP_AP_COV_ENV=$SKIP_AP_COV_ENV SKIP_AP_GIT_CHECK=$SKIP_AP_GIT_CHECK \
DO_AP_STM_ENV=$DO_AP_STM_ENV \
AP_DOCKER_BUILD=1 \
USER=${USER_NAME} \
Tools/environment_install/install-prereqs-ubuntu.sh -y
# Rectify git perms issue that seems to crop up only on OSX
RUN git config --global --add safe.directory $PWD
# 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" >> ~/.ardupilot_env
# Clone & install Micro-XRCE-DDS-Gen dependancy
RUN git clone --recurse-submodules https://github.com/ardupilot/Micro-XRCE-DDS-Gen.git /home/${USER_NAME}/Micro-XRCE-DDS-Gen \
&& cd /home/${USER_NAME}/Micro-XRCE-DDS-Gen \
&& ./gradlew assemble \
&& export AP_ENV_LOC="/home/${USER_NAME}/.ardupilot_env" \
&& echo "export PATH=\$PATH:$PWD/scripts" >> $AP_ENV_LOC
# 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
ENV BUILDLOGS=/tmp/buildlogs
# Cleanup
RUN sudo apt-get clean \
&& sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV CCACHE_MAXSIZE=1G
ENTRYPOINT ["/ardupilot_entrypoint.sh"]
CMD ["bash"]