Last active
May 7, 2024 11:57
-
-
Save jacknlliu/d9ead435ea44e6e3b6d7badfaf806cd2 to your computer and use it in GitHub Desktop.
use variable "DEBIAN_FRONTEND noninteractive" to apt-get noninteractive install and set environment and use shell script in Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV QT_BASE_DIR=/opt/qt55 | |
ENV QTDIR=$QT_BASE_DIR | |
ENV PATH=$QT_BASE_DIR/bin:$PATH | |
ENV LD_LIBRARY_PATH=$QT_BASE_DIR/lib/x86_64-linux-gnu:$QT_BASE_DIR/lib:$LD_LIBRARY_PATH | |
ENV PKG_CONFIG_PATH=$QT_BASE_DIR/lib/pkgconfig:$PKG_CONFIG_PATH | |
# Reconfigure locale | |
RUN locale-gen en_US.UTF-8 && dpkg-reconfigure locales | |
# Docker offical ENVIRONMETN REPLACEMENT | |
ENV foo /bar | |
WORKDIR ${foo} # WORKDIR /bar | |
ADD . $foo # ADD . /bar | |
COPY \$foo /quux # COPY $foo /quux | |
# ENV like shell script syntax | |
ENV abc=hello | |
ENV abc=bye def=$abc | |
ENV ghi=$abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forked from docker.io [tstumm/qt-opencv](https://hub.docker.com/r/tstumm/qt-opencv/~/dockerfile/) | |
ENV DEBIAN_FRONTEND noninteractive | |
# Install updates & requirements: | |
# * git, openssh-client - for Drone | |
# * curl, p7zip - to download & unpack Qt bundle | |
# * build-essential, pkg-config, libgl1-mesa-dev - basic Qt build requirements | |
# * libsm6, libice6, libxext6, libxrender1, libfontconfig1 - dependencies of Qt bundle run-file | |
RUN apt-get -qq update && apt-get -qq dist-upgrade && apt-get install -qq -y --no-install-recommends \ | |
git \ | |
openssh-client \ | |
ca-certificates \ | |
curl \ | |
p7zip \ | |
build-essential \ | |
pkg-config \ | |
libgl1-mesa-dev \ | |
libsm6 \ | |
libice6 \ | |
libxext6 \ | |
libxrender1 \ | |
libfontconfig1 \ | |
&& apt-get -qq clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup sshd login without passwd | |
RUN mkdir /var/run/sshd \ | |
&& echo 'root:root' | chpasswd \ | |
&& sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config \ | |
&& echo "export VISIBLE=now" >> /etc/profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use "&&" and "\" to write a shell script in Dockerfile | |
# This is a compile/build source codes example in Dockerfile | |
RUN cd /opt \ | |
&& wget https://github.com/Itseez/opencv/archive/3.0.0.zip \ | |
&& unzip 3.0.0.zip \ | |
&& cd opencv-3.0.0 \ | |
&& mkdir release \ | |
&& cd release \ | |
&& cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON .. \ | |
&& make -j4 \ | |
&& make install \ | |
&& bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf' \ | |
&& ldconfig \ | |
&& rm /opt/3.0.0.zip \ | |
&& rm -R /opt/opencv-3.0.0 | |
# use ";" and "&&" and "\" to write shell script in Dockerfile | |
RUN /bin/bash -c "while true;do env | sort && sleep ${SLEEP_SECONDS:-30};done" | |
RUN /bin/bash -c "source /application.sh" | |
# The application.sh like the following lines: | |
# while true; \ | |
# do env | sort && sleep ${SLEEP_SECONDS:-30}; \ | |
# done | |
# | |
# command2 | |
# | |
# command3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good to have examples. Appreciate it.