I would like to write a file into a Dockerfile. I don't want to import the file.
I would like the simplest solution, something like the solution that is not working. I would like to avoid to repeat many echo with each time the name of the file...
Thanks for help !
# This one is not working
RUN echo "[supervisord] \
nodaemon=true \
[program:ssh] \
command=service ssh start \
autorestart=true \
[program:nginx] \
command=service nginx start \
autorestart=true" >> /etc/supervisor/conf.d/supervisord.conf
# This one is working
# RUN echo '[supervisord]' >> /etc/supervisor/conf.d/supervisord.conf \
# && echo 'nodaemon=true' >> /etc/supervisor/conf.d/supervisord.conf \
# && echo '[program:ssh]' >> /etc/supervisor/conf.d/supervisord.conf \
# && echo 'command=service ssh start' >> /etc/supervisor/conf.d/supervisord.conf \
# && echo 'autorestart=true' >> /etc/supervisor/conf.d/supervisord.conf \
# && echo '[program:nginx]' >> /etc/supervisor/conf.d/supervisord.conf \
# && echo 'command=service nginx start' >> /etc/supervisor/conf.d/supervisord.conf \
# && echo 'autorestart=true' >> /etc/supervisor/conf.d/supervisord.conf
Not working
RUN echo $'[supervisord]\n\
nodaemon=true\n\
[program:ssh]\n\
command=service ssh start\n\
autorestart=true\n\
[program:nginx]\n\
command=service nginx start\n\
autorestart=true' > /etc/supervisor/conf.d/supervisord.conf
This is the image used by the Dockerfile above :
FROM debian:latest
# Run install with..
USER root
LABEL first_build="2021-01-28"
# Timezone Paris
ENV TZ Europe/Paris
RUN cp /usr/share/zoneinfo/Europe/Paris /etc/localtime
# Motd Dock'Ager
ADD var/motd.tar.gz /etc/update-motd.d/
COPY var/sources.list /etc/apt/sources.list
# SSH & Timezone & Munin
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
&& apt-get update \
&& apt-get upgrade -y && apt-get install -y \
openssh-server \
sudo \
nano \
zip \
unzip \
tar \
nginx \
munin \
munin-node \
munin-plugins-extra \
figlet \
ruby-full \
curl \
wget \
&& useradd -rm -d /home/test -s /bin/bash -g root -G sudo -u 1000 test \
&& echo 'test:test' | chpasswd \
&& echo 'root:root' | chpasswd \
&& cd /tmp \
&& wget https://github.com/busyloop/lolcat/archive/master.zip \
&& unzip master.zip \
&& cd lolcat-master/bin \
&& gem install lolcat \
&& sed -i '/pam_motd.so noupdate/s/^/#/g' /etc/pam.d/sshd \
&& chmod +x /etc/update-motd.d/* \
&& apt-get clean \
&& rm -rf /var/log/* \
&& rm -rf /var/lib/apt/lists/*
COPY var/sshd_config /etc/ssh/sshd_config