The discussion revolves around modifying a Dockerfile for a Discourse container. slackmoehrle wants to add custom shell scripts and a crontab to the container, but is unsure about the correct approach. Falco asks for clarification, and slackmoehrle explains their goal.
Falco suggests using the exec command in the containers/app.yml file to run custom commands, providing an example of downloading and executing a script. slackmoehrle tries this approach but encounters copy errors.
After Falco requests the error log, slackmoehrle shares the error message, revealing that the files are present on the host but the copy command fails. Falco explains that the /shared dir is mapped to /var/discourse/shared/standalone by default, which is causing the issue.
slackmoehrle makes an adjustment but still encounters an error. However, they eventually find success with Falco’s initial suggestion of using curl to download and execute a script, as seen in slackmoehrle’s final post.
I have a few other Docker containers and I run steps like this:
# Copy the current directory contents into the container at /app
COPY html /usr/share/nginx/html/
COPY dim.local.crt /etc/nginx/ssl/
COPY dim.local.key /etc/nginx/ssl/
COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/sites-enabled/
# Install any needed packages specified in requirements.txt
#RUN pip install -r requirements.txt
# need to restart nginx after COPY commands?
RUN
RUN apt-get update && \
apt-get install -y nano && \
rm -fr /var/lib/apt/lists/*
I need to do some similar steps to my Discourse container, but where is the Dockerfile? I read that maybe I could add these to containers/app.yml at the end, but I’m not confident.
Yup, I see that, but each time I rebuild I get copy errors:
## Any custom commands to run after building
run:
- exec: echo "Beginning of custom commands"
## If you want to set the 'From' email address for your first registration, uncomment and change:
## After getting the first signup email, re-comment the line. It only needs to run once.
#- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
- exec: cp /shared/rr/run_badges.sh /etc/cron.d/.
- exec: cp /shared/rr/badges /etc/cron.d/.
- exec: echo "End of custom commands"
I could indeed pull them from a url, that is a thought
The files are indeed present on the host:
# ls -al shared/rr/
badges run_badges.sh
#
Here is the error:
FAILED
--------------------
Pups::ExecError: cp /shared/rr/run_badges.sh /etc/cron.d/. failed with return #<Process::Status: pid 1457 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "cp /shared/rr/run_badges.sh /etc/cron.d/."
e23ff12630c8058c4b36ee8673404dafbe6791ec61aa630f1224400eba4e75e0
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.