Hi Sachin,
You can create a docker image easily following any Docker file, or docker-compose, etc. If you never create one before I'd recommend to take a look to official Docker documentation here (https://docs.docker.com/get-started/). Here it is one Dockerfile similar to the ones we use to create a moodle site:
You can create a docker image easily following any Docker file, or docker-compose, etc. If you never create one before I'd recommend to take a look to official Docker documentation here (https://docs.docker.com/get-started/). Here it is one Dockerfile similar to the ones we use to create a moodle site:
FROM ubuntu/nginx:latest
COPY /build/setup.sh /tmp/setup.sh
COPY /build/scripts /opt/scripts/
COPY /build/deploy_key.pri /root/.ssh/id_rsa
COPY /build/cron.json /opt/crons/cron.json
COPY /build/default.conf /etc/nginx/includes/default.conf
RUN bash /tmp/setup.sh
VOLUME ["/opt/app"]
VOLUME ["/opt/data"]
VOLUME ["/opt/logs"]
EXPOSE 80
CMD ["/bin/bash", "/opt/scripts/run.sh"]
COPY /build/setup.sh /tmp/setup.sh
COPY /build/scripts /opt/scripts/
COPY /build/deploy_key.pri /root/.ssh/id_rsa
COPY /build/cron.json /opt/crons/cron.json
COPY /build/default.conf /etc/nginx/includes/default.conf
RUN bash /tmp/setup.sh
VOLUME ["/opt/app"]
VOLUME ["/opt/data"]
VOLUME ["/opt/logs"]
EXPOSE 80
CMD ["/bin/bash", "/opt/scripts/run.sh"]
Two key steps:
- setup.sh script contains anything you need to add to the base image (eg, packages, moodle code, config files, etc)
- run.sh script contains the entry point of the container. It wakes up the web server daemon, etc
Other recommendations:
- Make sure you have mounted the /opt/data filesystem in a shared volume
- Make sure the code directory (/opt/app here) is in a local volume. We usually add the code to the image so it is loaded in a local docker volume.