uci-docker-build/Dockerfile

64 lines
1.9 KiB
Docker

# syntax=docker/dockerfile:latest
ARG BASE_IMAGE
FROM $BASE_IMAGE
ARG BASE_IMAGE
ARG SYSADMIN_PW
ARG LINUX_DISTRO=alpine
WORKDIR /build
# PACKAGES
RUN --mount=type=bind,source=.src/packages,target=/build/packages \
<<eot
echo -e "\n ************************************************* \n"
echo "Building Image from Base: $BASE_IMAGE"
echo "Distro: $LINUX_DISTRO; *****"
echo " ---- running packages install script ---"
cd packages; /bin/sh ./packages.sh; cd ..
echo -e "\n********************************************************"
eot
# END PACKAGES
# INITIALIZATION
RUN --mount=type=bind,source=.src/init,target=/build/init \
<<eot
echo -e "\n ************************************************* \n"
echo "****** Initializing Image with build source ******"
cd init
pwd; ls -la
if [[ -d env/ ]]; then
echo "copying env/ to /opt/env"
/bin/cp -R -p env/. /opt/env
ls -la /opt/env
fi
if [[ -f env/build.env ]]; then
source /opt/env/build.env
rm -f /opt/env/build.env
echo sourced /opt/env/build.env and deleted
fi
if [[ -d bin/ ]]; then
echo "copying bin/ to /opt/bin"
/bin/cp -R -p bin/. /opt/bin
chmod -R +x /opt/bin
ls -la /opt/bin
fi
echo " ---- running init script init.sh ---"
/bin/bash ./init.sh
echo "############## Finished run init build script(s) ###########################"
if [[ -f /opt/env/run.env ]]; then
echo "sourcing /opt/env/run.env from /etc/profile"
echo "&&&&&& last 10 of /etc/profile &&&&&"
echo -e "# added from image build\nsource /opt/env/run.env" >> /etc/profile
tail /etc/profile
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%"
fi
echo -e "\n ************* End Initialzation ************************"
eot
# END INITIALIZATION
# default command
CMD ["/bin/bash", "-l"]
# default
WORKDIR /opt