I try to execute a BASH script within a Dockerfile:
COPY data/install_ssh_keys.sh /tmp
RUN (chmod a+wxr /tmp/install_ssh_keys.sh)
RUN (chown dev:root /tmp/install_ssh_keys.sh)
USER dev
WORKDIR /tmp
RUN (if [ -f /tmp/install_ssh_keys.sh ]; then echo "file exists"; else echo "failure!"; fi)
RUN (if [ -x /tmp/install_ssh_keys.sh ]; then echo "file can be executed"; else echo "failure!"; fi)
RUN echo $(ls -l)
RUN /tmp/install_ssh_keys.sh
This Dockerfile works fine when I build the image from an Ubuntu host. But when I try to build it from my Windows 10 host, I have the following error:
$ docker build --tag ubuntu-dev --progress=plain .
...
#19 [15/69] COPY data/install_ssh_keys.sh /tmp
#19 sha256:abd4f5a09747d9bc354dea9881617cd47acecdf36bcbebba4f765e103f4055ed
#19 DONE 0.0s
#20 [16/69] RUN (chmod a+wxr /tmp/install_ssh_keys.sh)
#20 sha256:f19e3da11aef8eaa4b4562571a80503d44827017399f4591b3010c00522c367b
#20 DONE 0.4s
#21 [17/69] RUN (chown dev:root /tmp/install_ssh_keys.sh)
#21 sha256:f776fcc0ec96ba2e6ae7156d7be1b3c2ce91a3759da14edb6aa00eb650383601
#21 DONE 0.5s
#22 [18/69] WORKDIR /tmp
#22 sha256:45d47ee644a0bc9bba6b9abedb0eca9a873adcd581316ce122d0f2404dcf7d66
#22 DONE 0.0s
#23 [19/69] RUN (if [ -f /tmp/install_ssh_keys.sh ]; then echo "file exists"; else echo "failure!"; fi)
#23 sha256:1f5ca1b02d1d02d795fe090621d85bfc710f20b7bcf60b9a60f0e17532af7886
#23 0.541 file exists
#23 DONE 0.6s
#24 [20/69] RUN (if [ -x /tmp/install_ssh_keys.sh ]; then echo "file can be executed"; else echo "failure!"; fi)
#24 sha256:d63ceceb2f74533fc5e5b3967d54beb7a688f6d5e8178ab9810a98433e672d70
#24 0.585 file can be executed
#24 DONE 0.6s
#25 [21/69] RUN echo $(ls -l)
#25 sha256:dd85b7732befdea5dbaa2beaf3b3b539d8f5aec81ea44ebecbb6c4604dca1077
#25 0.518 total 4 -rw-r--r-- 1 root root 0 Mar 8 16:57 f5 -rwxrwxrwx 1 dev root 3521 Mar 8 15:14 install_ssh_keys.sh
#25 DONE 0.5s
#26 [22/69] RUN /tmp/install_ssh_keys.sh
#26 sha256:7e437b794e6418f496bf2207cf9a844e2411cb46eae3849000557dcdd3fa8719
#26 0.498 /bin/sh: 1: /tmp/install_ssh_keys.sh: not found
#26 ERROR: executor failed running [/bin/sh -c /tmp/install_ssh_keys.sh]: exit code: 127
------
> [22/69] RUN /tmp/install_ssh_keys.sh:
------
executor failed running [/bin/sh -c /tmp/install_ssh_keys.sh]: exit code: 127
It tells me that the file /tmp/install_ssh_keys.sh
does not exist!
But it exists :
#23 [19/68] RUN (if [ -f /tmp/install_ssh_keys.sh ]; then echo "success"; else echo "failure"; fi)
#23 sha256:036bc66c57c595e76b19307541de78e9cc9841340b9a9a7a63250f4e1b85e5f8
#23 0.455 success
#23 DONE 0.5s
#24 [20/68] RUN echo $(ls -l)
#24 sha256:e660f93a3b0b1c9f6f00f27774d6a8c744276b10c6b9eb508e85d3e8f1cc75b9
#24 0.449 total 4 -rw-r--r-- 1 root root 0 Mar 8 16:55 f4 -rwxrwxrwx 1 dev root 3521 Mar 8 15:14 install_ssh_keys.sh
#24 DONE 0.5s
=
And it can be executed:
#24 [20/69] RUN (if [ -x /tmp/install_ssh_keys.sh ]; then echo "file can be executed"; else echo "failure!"; fi)
#24 sha256:d63ceceb2f74533fc5e5b3967d54beb7a688f6d5e8178ab9810a98433e672d70
#24 0.585 file can be executed
#24 DONE 0.6s
And, again, if I build it from an Ubuntu host (instead of a Windows 10 host), it works just fine.
Any idea ?
Please note that I've already tried many things:
...
USER dev
WORKDIR /tmp
RUN echo $(ls -l)
RUN ./install_ssh_keys.sh
or
...
USER dev
RUN echo $(ls -l)
RUN /tmp/install_ssh_keys.sh
But none of these attempts work.
Added
The entire Dockerfile:
FROM ubuntu:jammy
RUN (echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker)
RUN (echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker)
RUN (apt-get update)
RUN (apt-get install -y ssh expect)
RUN (apt-get install -y build-essential)
RUN (apt-get install -y software-properties-common)
RUN (apt-get install -y wget \
openssl \
man-db \
git \
gdb \
manpages-dev \
manpages-posix \
manpages-posix-dev \
autoconf \
automake \
libtool \
libssl-dev \
sudo)
# -----------------------------------------------------------------
# Create and configure users.
# -----------------------------------------------------------------
RUN (useradd -rm -d /home/dev -s /bin/bash -g root -G sudo -u 1000 dev)
RUN (echo 'dev:dev' | chpasswd)
RUN (echo 'root:root' | chpasswd)
# -----------------------------------------------------------------
# Configure SSH server.
# -----------------------------------------------------------------
RUN (ssh-keygen -A; \
sed -i 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config; \
sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config; \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config; \
sed -iE 's/\s*#\s*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config; )
RUN (mkdir -p /root/.ssh/; \
echo "StrictHostKeyChecking=no" > /root/.ssh/config; \
echo "UserKnownHostsFile=/dev/null" >> /root/.ssh/config)
RUN (touch "/tmp/f5")
COPY data/install_ssh_keys.sh /tmp
RUN (chmod a+wxr /tmp/install_ssh_keys.sh)
RUN (chown dev:root /tmp/install_ssh_keys.sh)
USER dev
WORKDIR /tmp
RUN (if [ -f /tmp/install_ssh_keys.sh ]; then echo "file exists"; else echo "failure!"; fi)
RUN (if [ -x /tmp/install_ssh_keys.sh ]; then echo "file can be executed"; else echo "failure!"; fi)
RUN echo $(ls -l)
RUN /tmp/install_ssh_keys.sh
# -----------------------------------------------------------------
# Update CMAKE. Use "cmake --version" to check.
# The new version of "cmake" is installed under "/usr/local/bin".
# The original version will still be under "/usr/bin".
# -----------------------------------------------------------------
WORKDIR /tmp
RUN (wget https://github.com/Kitware/CMake/releases/download/v3.24.3/cmake-3.24.3.tar.gz)
RUN (tar zxvf cmake-3.24.3.tar.gz)
WORKDIR /tmp/cmake-3.24.3
RUN (./bootstrap && gmake && make install)
WORKDIR /tmp
RUN (rm -rf /tmp/cmake-3.24.3 cmake-3.24.3.tar.gz)
# -----------------------------------------------------------------
# Add packages here so we can add more without the need to
# recompile CMAKE.
# -----------------------------------------------------------------
RUN (apt-get install -y zip \
unzip \
locate \
jq \
tree \
vim \
curl)
# Specific tools
RUN (apt clean)
# -----------------------------------------------------------------
# Install RUST compilation toolchain.
# -----------------------------------------------------------------
USER dev
RUN (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y)
ENV PATH="${PATH}:/home/dev/.cargo/bin"
RUN (rustup update)
# -----------------------------------------------------------------
# Install JANSSON (for personal use)
# -----------------------------------------------------------------
USER dev
RUN (mkdir -p ${HOME}/componants/jansson-2.13)
WORKDIR /tmp
RUN (wget http://digip.org/jansson/releases/jansson-2.13.tar.gz)
RUN (tar xzvf jansson-2.13.tar.gz)
RUN (rm jansson-2.13.tar.gz)
WORKDIR /tmp/jansson-2.13
RUN (./configure --prefix=${HOME}/componants/jansson-2.13 --exec-prefix=${HOME}/componants/jansson-2.13)
RUN (make && make install)
WORKDIR /tmp
RUN (rm -rf jansson-2.13)
# -----------------------------------------------------------------
# Install the version 7.88 of libcurl (for personal use)
# -----------------------------------------------------------------
USER dev
RUN (mkdir -p ${HOME}/componants/curl-7.88.0)
WORKDIR /tmp
RUN (wget https://curl.se/download/curl-7.88.0.tar.gz)
RUN (tar xzvf curl-7.88.0.tar.gz)
RUN (rm curl-7.88.0.tar.gz)
WORKDIR /tmp/curl-7.88.0
RUN (./configure --with-openssl --prefix=${HOME}/componants/curl-7.88.0 --exec-prefix=${HOME}/componants/curl-7.88.0)
RUN (make && make install)
WORKDIR /tmp
RUN (rm -rf curl-7.88.0)
# -----------------------------------------------------------------
# Install PCRE2 (for personal use)
# -----------------------------------------------------------------
USER dev
RUN (mkdir -p ${HOME}/componants/pcre2-10.42)
WORKDIR /tmp
RUN (wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz)
RUN (tar xzvf pcre2-10.42.tar.gz)
RUN (rm pcre2-10.42.tar.gz)
WORKDIR /tmp/pcre2-10.42
RUN (./configure --prefix=${HOME}/componants/pcre2-10.42 --exec-prefix=${HOME}/componants/pcre2-10.42)
RUN (make && make install)
WORKDIR /tmp
RUN (rm -rf pcre2-10.42)
# -----------------------------------------------------------------
# Install Chilkat (for personal use)
# -----------------------------------------------------------------
USER dev
WORKDIR /home/dev/componants
RUN (wget https://chilkatdownload.com/9.5.0.93/chilkat-9.5.0-x86_64-linux-gcc.tar.gz)
RUN (tar zxvf chilkat-9.5.0-x86_64-linux-gcc.tar.gz)
RUN (rm chilkat-9.5.0-x86_64-linux-gcc.tar.gz)
# -----------------------------------------------------------------
# Update tools and environments.
# -----------------------------------------------------------------
USER root
RUN (updatedb)
# -----------------------------------------------------------------
# Start the SSH daemon.
# -----------------------------------------------------------------
# 22 for ssh server. 7777 for gdb server.
EXPOSE 22 7777
RUN service ssh start
ENTRYPOINT ["/usr/sbin/sshd", "-D"]
The script install_ssh_keys.sh
:
#!/bin/bash
#
# The set -e option instructs bash to immediately exit if any command has a
# non-zero exit status.
set -e
if [ -z ${HOME+x} ]; then
echo "FATAL: variable HOME is NOT defined! What's wrong!";
exit 1
fi
# -------------------------------------------------
# Configuration
# -------------------------------------------------
# Doc: https://www.thedigitalcatonline.com/blog/2018/04/25/rsa-keys/
#
# Note: the last "field" of the public key (here: "denis@lab") is is a comment, and can be
# changed or ignored at will. It is set to "user@host" by default by ssh-keygen.
# See: https://serverfault.com/questions/743548/what-significance-does-the-user-host-at-the-end-of-an-ssh-public-key-file-hold
SSH_PUB_KEY=$(cat <<"EOS"
ssh-rsa AAAA... denis@lab
EOS
)
declare -r SSH_PUB_KEY
# Note: The private key must be store with file permission "600" (chmod 600 /path/to/file)
SSH_PRIV_KEY=$(cat <<"EOS"
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAuqwIsz0rpJ8eSx+kAB1ZTwXLuOP3rhuNjBCdrD7Qth7eS5/b
...
-----END RSA PRIVATE KEY-----
EOS
)
declare -r SSH_PRIV_KEY
# -------------------------------------------------
# End of configuration
# -------------------------------------------------
declare -r SSH_DIR="${HOME}/.ssh"
# Create the ".ssh" directory if necessary.
if [ ! -d "${SSH_DIR}" ]; then
echo "Create directory \"${SSH_DIR}\""
mkdir "${SSH_DIR}"
chmod 0700 "${SSH_DIR}"
fi
cd "${SSH_DIR}"
echo "${SSH_PUB_KEY}" >> authorized_keys
chmod 0444 authorized_keys
cd "${HOME}"
GITHUB repository:
https://github.com/denis-beurive/ubuntu-docker-dev
=> Works just fine from an Ubuntu host!
Added
I tried to add this bloc:
RUN (echo "#!/bin/bash" > /tmp/test.sh; \
echo "set -e" >> /tmp/test.sh; \
echo "echo SUCCESS" >> /tmp/test.sh;)
RUN (chmod a+xr /tmp/test.sh)
RUN (/tmp/test.sh)
And it works:
#18 [15/72] RUN (echo "#!/bin/bash" > /tmp/test.sh; echo "set -e" >> /tmp/test.sh; echo "echo SUCCESS" >> /tmp/test.sh;)
#18 sha256:6cd2d9eefabdd17470278d4822f8c9ddf2fd9d9db6296d1d972e70fa13fe90dc
#18 DONE 0.5s
#19 [16/72] RUN (chmod a+xr /tmp/test.sh)
#19 sha256:aec9371af76e5ed2f491ac6ad7a57537477557df1e7d851e4c5a4a3e1bd87139
#19 DONE 0.5s
#20 [17/72] RUN (/tmp/test.sh)
#20 sha256:f078e6d233cd937350c17359f604bd639f3af25ee153aac802ca0b9fad989e4c
#20 0.458 SUCCESS
#20 DONE 0.5s
Thus, it seems that the problem comes from the COPY
or ADD
(I've tried both) - only from a Windows 10 host.
Added
The script to execute (install_ssh_keys.sh
) does not contain any "weird" characters:
denis@labo:~/Documents/github/ubuntu-docker/data$ cat -v install_ssh_keys.sh | head
#!/bin/bash
#
# The set -e option instructs bash to immediately exit if any command has a
# non-zero exit status.
set -e
if [ -z ${HOME+x} ]; then
echo "FATAL: variable HOME is NOT defined! What's wrong!";
exit 1
Added
There is a CTRL M
in the file Dockerfile
itself.
But this is normal. The Dockerfile
should be read correctly under Windows anyway...
Added final solution
I've found a solution, a workaround.
Instead to copying the script to execute from the host to the container, I generate the script from within the Dockerfile
.
Please note that I have no idea why the solution that consists of copying the script from the host to the container (using ADD
or COPY
) works from an Ubuntu host, but not from a Windows host. But, this workaround works well from both OS!
Here is the final Dockerfile
:
FROM ubuntu:jammy
RUN (echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker)
RUN (echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker)
RUN (apt-get update)
RUN (apt-get install -y ssh expect)
RUN (apt-get install -y build-essential)
RUN (apt-get install -y software-properties-common)
RUN (apt-get install -y wget \
openssl \
man-db \
git \
gdb \
manpages-dev \
manpages-posix \
manpages-posix-dev \
autoconf \
automake \
libtool \
libssl-dev \
sudo)
# -----------------------------------------------------------------
# Create and configure users.
# -----------------------------------------------------------------
RUN (useradd -rm -d /home/dev -s /bin/bash -g root -G sudo -u 1000 dev)
RUN (echo 'dev:dev' | chpasswd)
RUN (echo 'root:root' | chpasswd)
# -----------------------------------------------------------------
# Configure SSH server.
# -----------------------------------------------------------------
RUN (ssh-keygen -A; \
sed -i 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config; \
sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config; \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config; \
sed -iE 's/\s*#\s*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config; )
RUN (mkdir -p /root/.ssh/; \
echo "StrictHostKeyChecking=no" > /root/.ssh/config; \
echo "UserKnownHostsFile=/dev/null" >> /root/.ssh/config)
# For some unknown reason, if we copy the file "/tmp/install_ssh_keys.sh" from the host to the container, from a Windows host (only), it fails.
# The workaroud is to generate the file here.
# See https://stackoverflow.com/questions/54397706/how-to-output-a-multiline-string-in-dockerfile-with-a-single-command
RUN echo '#!/bin/bash\n\
#\n\
# The set -e option instructs bash to immediately exit if any command has a\n\
# non-zero exit status. \n\
\n\
set -e\n\
\n\
if [ -z ${HOME+x} ]; then\n\
echo "FATAL: variable HOME is NOT defined! What is wrong!";\n\
exit 1\n\
fi\n\
\n\
# -------------------------------------------------\n\
# Configuration\n\
# -------------------------------------------------\n\
\n\
# Doc: https://www.thedigitalcatonline.com/blog/2018/04/25/rsa-keys/\n\
#\n\
# Note: the last "field" of the public key (here: "denis@lab") is is a comment, and can be \n\
# changed or ignored at will. It is set to "user@host" by default by ssh-keygen.\n\
# See: https://serverfault.com/questions/743548/what-significance-does-the-user-host-at-the-end-of-an-ssh-public-key-file-hold\n\
\n\
SSH_PUB_KEY=$(cat <<"EOS"\n\
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6rAizPSuknx5LH6QAHVlPBcu44/euG42MEJ2sPtC2Ht5Ln9sI7T2xZxvRYTWXCEzGv3yB16ZH3zJm5liTP+V7CmahgpfagX0gm6/3+EFaKeRNQ1Lvh0d7rVO8L1DpCOG3oP952flboy2U7SuKcNHjNo+a4NYInkz+wqjnFEERbahyBgKLsKo6fyTu9g9gSIxBorsbDud37fQ6VJ424Ub69gRELRTQbmcUhJEuLATgYHx0CZPRopEU5JSdBVq6UfkcnQ9AGTH5VdhLmLnj04NEqyhA1cNu2H5E7L/Sx7xPNGoUhzmN4Z/EhvVHqSO/YfzZnxuMcmTJfIrsVXajR/xb denis@lab\n\
EOS\n\
)\n\
declare -r SSH_PUB_KEY\n\
\n\
# Note: The private key must be store with file permission "600" (chmod 600 /path/to/file)\n\
\n\
SSH_PRIV_KEY=$(cat <<"EOS"\n\
-----BEGIN RSA PRIVATE KEY-----\n\
MIIEogIBAAKCAQEAuqwIsz0rpJ8eSx+kAB1ZTwXLuOP3rhuNjBCdrD7Qth7eS5/b\n\
CO09sWcb0WE1lwhMxr98gdemR98yZuZYkz/lewpmoYKX2oF9IJuv9/hBWinkTUNS\n\
74dHe61TvC9Q6Qjht6D/edn5W6MtlO0rinDR4zaPmuDWCJ5M/sKo5xRBEW2ocgYC\n\
i7CqOn8k7vYPYEiMQaK7Gw7nd+30OlSeNuFG+vYERC0U0G5nFISRLiwE4GB8dAmT\n\
0aKRFOSUnQVaulH5HJ0PQBkx+VXYS5i549ODRKsoQNXDbth+ROy/0se8TzRqFIc5\n\
jeGfxIb1R6kjv2H82Z8bjHJkyXyK7FV2o0f8WwIDAQABAoIBAFuLusiMGzckgaq9\n\
3aPgwMesQ/hsdC8CfCxQicLLG3f1M3dK8hQypKq3skDAt5NWErD1f439wCJHJ2Sn\n\
WpD8KQJqW2KhtO8HyeGP+IBXU1VwbfImLioh4cCZhBMp8TgXjvqLDj8n0s5J/DSp\n\
C01dftE7FLoTwWOAnqnhtQt+N1rf4eA6ZONnGGWJc58h3nZr1MbwMaME869btjXS\n\
mnD8j+BSL4dpyNVk20Lr8oLmm2DkYQpc2e4qBu0apuX6MZXU59PkXvgFNw6iZ94t\n\
6kc/q5xVunM8jdVQbdgC+1zBYvBGWO2Ecfqst+IrNf0aQClZ+q3sCgO9pIjuRIGO\n\
XYjE8WECgYEA330REFVPtPKhQU7D653m6N8NMhIDp/2qx4wuKTJfZyFQKFYbMC2s\n\
dlUMLg6yWjBhlp7T1HPgD6LcPbZhMpBLC7ne04gvniKf6BaGjJDpu8ifGnlr1XdT\n\
GcO8+mbEn9lGnRVR+i0M4BNU/ggiT3FSgOi2UFUeNR4BGRala7NdY8cCgYEA1dPi\n\
I7WhUXLM1aJh4tM3pv7B0SRkPrXg3z8sWWXRS8lyPwDz6QoBHWLr5wDRAqibIHdl\n\
sgZFWTZgf2wxNRFIjANqIV3XS/6GWbmY0PuJL9wgxdykEQ/41I4NPUBz5nGV62zE\n\
BNt5EMEh+HTT27MjHCs5dyNCZ+Ih9/gjUlf8Os0CgYA0KvuKtn9Om7xshDhTjZ5T\n\
CY4I/A+CbUIqJly4HRwL9MjDQaZDDsZNMPkQ3zleuCBvik+kLhBFVhzXAvWZWflK\n\
mW6cLhP/c9Gj2W467bDBtsj84w7620m4n+pDAS4wqgVDsbBbF50DyT9ztO5dYPSD\n\
Rs8X3WaZu5FCC/k9NLc+DQKBgAwnT+oxr6qeeNAHu8KVuMsQHdoSVHRQCCkIQTAP\n\
nnbNS2YTWsm7HNcbwUbPABJDnRWaU7hrrNNmSNPVRXK7ucDjjMu6trsGC4LcDriK\n\
I4EJ5P76DIU/wCfsrwn1OOE3QYsxEm8oPlhaceDaWxRYuT0no8uGwIaBDuc2PmO2\n\
xopdAoGAUjTmdKTaLCXTxa1bIiTTp++sG6wo9WWY0iPyK2CZg6bTt+iUKqcRVLmi\n\
oYvYkHykqCyZQOWKnSjM/Hu4LlbH88jVa/9AClALP9CupUWWJDSRkLuQgjFraPrk\n\
kTLvjpvfekRQdAIsPN9uHCEUnKtgKQKCTSwPCmE2nL1EVj7SLOw=\n\
-----END RSA PRIVATE KEY-----\n\
EOS\n\
)\n\
declare -r SSH_PRIV_KEY\n\
\n\
# -------------------------------------------------\n\
# End of configuration\n\
# -------------------------------------------------\n\
\n\
declare -r SSH_DIR="${HOME}/.ssh"\n\
\n\
# Create the ".ssh" directory if necessary.\n\
if [ ! -d "${SSH_DIR}" ]; then\n\
echo "Create directory \"${SSH_DIR}\""\n\
mkdir "${SSH_DIR}"\n\
chmod 0700 "${SSH_DIR}"\n\
fi\n\
\n\
\n\
cd "${SSH_DIR}"\n\
echo "${SSH_PUB_KEY}" >> authorized_keys\n\
chmod 0444 authorized_keys\n\
cd "${HOME}"\n\
' > /tmp/install_ssh_keys.sh
RUN (chmod a+wxr /tmp/install_ssh_keys.sh)
RUN (chown dev:root /tmp/install_ssh_keys.sh)
USER dev
RUN (if [ -f /tmp/install_ssh_keys.sh ]; then echo "file exists"; else echo "failure!"; fi)
RUN (if [ -x /tmp/install_ssh_keys.sh ]; then echo "file can be executed"; else echo "failure!"; fi)
RUN (/tmp/install_ssh_keys.sh)
USER root
RUN (if [ -f /tmp/install_ssh_keys.sh ]; then echo "file exists"; else echo "failure!"; fi)
RUN (if [ -x /tmp/install_ssh_keys.sh ]; then echo "file can be executed"; else echo "failure!"; fi)
RUN (/tmp/install_ssh_keys.sh)
RUN (rm /tmp/install_ssh_keys.sh)
# -----------------------------------------------------------------
# Update CMAKE. Use "cmake --version" to check.
# The new version of "cmake" is installed under "/usr/local/bin".
# The original version will still be under "/usr/bin".
# -----------------------------------------------------------------
WORKDIR /tmp
RUN (wget https://github.com/Kitware/CMake/releases/download/v3.24.3/cmake-3.24.3.tar.gz)
RUN (tar zxvf cmake-3.24.3.tar.gz)
WORKDIR /tmp/cmake-3.24.3
RUN (./bootstrap && gmake && make install)
WORKDIR /tmp
RUN (rm -rf /tmp/cmake-3.24.3 cmake-3.24.3.tar.gz)
# -----------------------------------------------------------------
# Add packages here so we can add more without the need to
# recompile CMAKE.
# -----------------------------------------------------------------
RUN (apt-get install -y zip \
unzip \
locate \
jq \
tree \
vim \
curl)
# Specific tools
RUN (apt clean)
# -----------------------------------------------------------------
# Install RUST compilation toolchain.
# -----------------------------------------------------------------
USER dev
RUN (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y)
ENV PATH="${PATH}:/home/dev/.cargo/bin"
RUN (rustup update)
# -----------------------------------------------------------------
# Install JANSSON (for personal use)
# -----------------------------------------------------------------
USER dev
RUN (mkdir -p ${HOME}/componants/jansson-2.13)
WORKDIR /tmp
RUN (wget http://digip.org/jansson/releases/jansson-2.13.tar.gz)
RUN (tar xzvf jansson-2.13.tar.gz)
RUN (rm jansson-2.13.tar.gz)
WORKDIR /tmp/jansson-2.13
RUN (./configure --prefix=${HOME}/componants/jansson-2.13 --exec-prefix=${HOME}/componants/jansson-2.13)
RUN (make && make install)
WORKDIR /tmp
RUN (rm -rf jansson-2.13)
# -----------------------------------------------------------------
# Install the version 7.88 of libcurl (for personal use)
# -----------------------------------------------------------------
USER dev
RUN (mkdir -p ${HOME}/componants/curl-7.88.0)
WORKDIR /tmp
RUN (wget https://curl.se/download/curl-7.88.0.tar.gz)
RUN (tar xzvf curl-7.88.0.tar.gz)
RUN (rm curl-7.88.0.tar.gz)
WORKDIR /tmp/curl-7.88.0
RUN (./configure --with-openssl --prefix=${HOME}/componants/curl-7.88.0 --exec-prefix=${HOME}/componants/curl-7.88.0)
RUN (make && make install)
WORKDIR /tmp
RUN (rm -rf curl-7.88.0)
# -----------------------------------------------------------------
# Install PCRE2 (for personal use)
# -----------------------------------------------------------------
USER dev
RUN (mkdir -p ${HOME}/componants/pcre2-10.42)
WORKDIR /tmp
RUN (wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz)
RUN (tar xzvf pcre2-10.42.tar.gz)
RUN (rm pcre2-10.42.tar.gz)
WORKDIR /tmp/pcre2-10.42
RUN (./configure --prefix=${HOME}/componants/pcre2-10.42 --exec-prefix=${HOME}/componants/pcre2-10.42)
RUN (make && make install)
WORKDIR /tmp
RUN (rm -rf pcre2-10.42)
# -----------------------------------------------------------------
# Install Chilkat (for personal use)
# -----------------------------------------------------------------
USER dev
WORKDIR /home/dev/componants
RUN (wget https://chilkatdownload.com/9.5.0.93/chilkat-9.5.0-x86_64-linux-gcc.tar.gz)
RUN (tar zxvf chilkat-9.5.0-x86_64-linux-gcc.tar.gz)
RUN (rm chilkat-9.5.0-x86_64-linux-gcc.tar.gz)
# -----------------------------------------------------------------
# Update tools and environments.
# -----------------------------------------------------------------
USER root
RUN (updatedb)
# -----------------------------------------------------------------
# Start the SSH daemon.
# -----------------------------------------------------------------
# 22 for ssh server. 7777 for gdb server.
EXPOSE 22 7777
RUN service ssh start
ENTRYPOINT ["/usr/sbin/sshd", "-D"]