mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Dockerfile overhaul (#1726)
Create entrypoint to orchestrate the build steps Supported commands: make, ninja Passes additional arguments to the make / ninja command at the end (like -jNN) There is a shortcut to make -jNN by just specifying -jNN Anything else will be directly executed (like getting a shell into the container with bash -li is still possible)
This commit is contained in:
parent
b53032a8a5
commit
75ece38725
@ -10,32 +10,40 @@ VOLUME /havoc
|
|||||||
WORKDIR /havoc/firmware
|
WORKDIR /havoc/firmware
|
||||||
|
|
||||||
# Fetch dependencies from APT
|
# Fetch dependencies from APT
|
||||||
RUN apt-get update && \
|
RUN apt-get update \
|
||||||
apt-get install -y git tar wget dfu-util cmake python3 ccache bzip2 liblz4-tool curl && \
|
&& apt-get install -y git tar wget dfu-util cmake python3 ccache bzip2 liblz4-tool curl ninja-build \
|
||||||
apt-get -qy autoremove
|
&& apt-get -qy autoremove \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
#Install current pip from PyPa
|
#Install current pip from PyPa
|
||||||
RUN curl https://bootstrap.pypa.io/pip/3.4/get-pip.py -o get-pip.py && \
|
RUN curl https://bootstrap.pypa.io/pip/3.4/get-pip.py -o get-pip.py && \
|
||||||
python3 get-pip.py
|
python3 get-pip.py
|
||||||
|
|
||||||
#Fetch additional dependencies from Python 3.x pip
|
#Fetch additional dependencies from Python 3.x pip
|
||||||
RUN pip install pyyaml
|
RUN pip install pyyaml \
|
||||||
RUN ln -s /usr/bin/python3 /usr/bin/python && \
|
&& ln -s /usr/bin/python3 /usr/bin/python \
|
||||||
ln -s /usr/bin/pip3 /usr/bin/pip
|
&& ln -s /usr/bin/pip3 /usr/bin/pip
|
||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
ENV LC_ALL C.UTF-8
|
ENV LC_ALL C.UTF-8
|
||||||
|
|
||||||
# Grab the GNU ARM toolchain from arm.com
|
# Grab the GNU ARM toolchain from arm.com
|
||||||
# Then extract contents to /opt/build/armbin/
|
# Then extract contents to /opt/build/armbin/
|
||||||
RUN mkdir /opt/build && cd /opt/build && \
|
RUN mkdir /opt/build \
|
||||||
wget -O gcc-arm-none-eabi $ARMBINURL && \
|
&& cd /opt/build \
|
||||||
mkdir armbin && \
|
&& wget -O gcc-arm-none-eabi $ARMBINURL \
|
||||||
tar --strip=1 -xjvf gcc-arm-none-eabi -C armbin
|
&& mkdir armbin \
|
||||||
|
&& tar --strip=1 -xjvf gcc-arm-none-eabi -C armbin
|
||||||
|
|
||||||
# Configure CCACHE
|
# Configure CCACHE
|
||||||
RUN mkdir ~/bin && cd ~/bin && \
|
RUN mkdir ~/bin \
|
||||||
for tool in gcc g++ cpp c++;do ln -s $(which ccache) arm-none-eabi-$tool;done
|
&& cd ~/bin \
|
||||||
|
&& for tool in gcc g++ cpp c++; do \
|
||||||
|
ln -s $(which ccache) arm-none-eabi-$tool \
|
||||||
|
; done
|
||||||
|
|
||||||
CMD cd .. && cd build && \
|
ADD firmware/tools/docker-entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
cmake .. && make ppfw
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
|
||||||
|
# replace make with ninja temporarily while building your image if you prefer to use that by default
|
||||||
|
CMD ["make"]
|
||||||
|
@ -10,32 +10,40 @@ VOLUME /havoc
|
|||||||
WORKDIR /havoc/firmware
|
WORKDIR /havoc/firmware
|
||||||
|
|
||||||
# Fetch dependencies from APT
|
# Fetch dependencies from APT
|
||||||
RUN apt-get update && \
|
RUN apt-get update \
|
||||||
apt-get install -y git tar wget dfu-util cmake python3 ccache bzip2 liblz4-tool curl && \
|
&& apt-get install -y git tar wget dfu-util cmake python3 ccache bzip2 liblz4-tool curl ninja-build \
|
||||||
apt-get -qy autoremove
|
&& apt-get -qy autoremove \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
#Install current pip from PyPa
|
#Install current pip from PyPa
|
||||||
RUN curl https://bootstrap.pypa.io/pip/3.4/get-pip.py -o get-pip.py && \
|
RUN curl https://bootstrap.pypa.io/pip/3.4/get-pip.py -o get-pip.py && \
|
||||||
python3 get-pip.py
|
python3 get-pip.py
|
||||||
|
|
||||||
#Fetch additional dependencies from Python 3.x pip
|
#Fetch additional dependencies from Python 3.x pip
|
||||||
RUN pip install pyyaml
|
RUN pip install pyyaml \
|
||||||
RUN ln -s /usr/bin/python3 /usr/bin/python && \
|
&& ln -s /usr/bin/python3 /usr/bin/python \
|
||||||
ln -s /usr/bin/pip3 /usr/bin/pip
|
&& ln -s /usr/bin/pip3 /usr/bin/pip
|
||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
ENV LC_ALL C.UTF-8
|
ENV LC_ALL C.UTF-8
|
||||||
|
|
||||||
# Grab the GNU ARM toolchain from arm.com
|
# Grab the GNU ARM toolchain from arm.com
|
||||||
# Then extract contents to /opt/build/armbin/
|
# Then extract contents to /opt/build/armbin/
|
||||||
RUN mkdir /opt/build && cd /opt/build && \
|
RUN mkdir /opt/build \
|
||||||
wget -O gcc-arm-none-eabi $ARMBINURL && \
|
&& cd /opt/build \
|
||||||
mkdir armbin && \
|
&& wget -O gcc-arm-none-eabi $ARMBINURL \
|
||||||
tar --strip=1 -xjvf gcc-arm-none-eabi -C armbin
|
&& mkdir armbin \
|
||||||
|
&& tar --strip=1 -xjvf gcc-arm-none-eabi -C armbin
|
||||||
|
|
||||||
# Configure CCACHE
|
# Configure CCACHE
|
||||||
RUN mkdir ~/bin && cd ~/bin && \
|
RUN mkdir ~/bin \
|
||||||
for tool in gcc g++ cpp c++;do ln -s $(which ccache) arm-none-eabi-$tool;done
|
&& cd ~/bin \
|
||||||
|
&& for tool in gcc g++ cpp c++; do \
|
||||||
|
ln -s $(which ccache) arm-none-eabi-$tool \
|
||||||
|
; done
|
||||||
|
|
||||||
CMD cd .. && cd build && \
|
ADD firmware/tools/docker-entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
cmake .. && make ppfw
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
|
||||||
|
# replace make with ninja temporarily while building your image if you prefer to use that by default
|
||||||
|
CMD ["make"]
|
||||||
|
34
firmware/tools/docker-entrypoint.sh
Executable file
34
firmware/tools/docker-entrypoint.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e # exit immediatelly on any failure
|
||||||
|
|
||||||
|
build_make() {
|
||||||
|
cd ..
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make "$@"
|
||||||
|
exit 0 # Report success :)
|
||||||
|
}
|
||||||
|
|
||||||
|
build_ninja() {
|
||||||
|
cd ..
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake -G Ninja ..
|
||||||
|
ninja "$@"
|
||||||
|
exit 0 # Report success :)
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" = 'make' ]; then # build the default (or specified) target with make
|
||||||
|
shift # remove the first item from $@ as we consumed it, we can then pass the rest on to make
|
||||||
|
build_make "$@"
|
||||||
|
elif [[ $1 == -j* ]]; then # allow passing -j without typing make_default
|
||||||
|
# dont shift here as we wanna pass the -j
|
||||||
|
build_make "$@"
|
||||||
|
elif [ "$1" = 'ninja' ]; then # build the default (or specified) target with ninja
|
||||||
|
shift # remove the first item from $@ as we consumed it, we can then pass the rest on to make
|
||||||
|
build_ninja "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
Loading…
Reference in New Issue
Block a user