Gitlab CI for apache project
Recently I have started working on Gitlab and as part of learning I have focused on the Gitlab CI process for my future projects. I have installed gitlab runner with executor as docker. Till here everything is fine. I have got a website which contains HTML pages and I am deploying it in the default apache web server path (/var/www/html). Here is the .gitlab-ci.yml file I am using for the build:
image: centos:7 test:app: script: - yum install -y httpd git ssh - cp -R HTML/* /var/www/html/
Till here the build is getting properly but in order to make the apache up and run the test I am unable to do it. When I add this command in the script, e.g.:
image: centos:7 test:app: script: - yum install -y httpd git ssh - cp -R HTML/* /var/www/html/ - sudo apachectl start or /usr/sbin/httpd start
…I am getting an error as “Command not found”.
How to make the apache instance up and test?
One Solution collect form web for “Gitlab CI for apache project”
Docker containers by default run as root, so there’s no need to sudo and I don’t believe the centos image from the Docker Hub includes the tool.
When running a process as a container, you don’t launch it via systemd or any of the other init systems, you need to spawn it as a foreground process for docker to attach to. It becomes pid 1, it’s the only process launched (no ssh daemon or other processes you may expect), and when it exits or is killed, the container is stopped. The way to do this with apache according to the repository on Docker Hub where it’s already created is the following Dockerfile entry:
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]