In this Service, I created a container that contains a portfolio Website using another web server called Apache2
Apache is the most commonly used Web server on Linux systems. Web servers are used to serve Web pages requested by client computers. Clients typically request and view Web pages using Web browser applications such as Firefox, Opera, Chromium, or Internet Explorer.
I created a Dockerfile below :
# base image
FROM debian:buster
# install apache2 webserver
RUN apt update && apt install -y apache2
# create folder for the website files and (by Default the configuration of the owner is www-data in debian configuration of Apache2)
# Since that is the default configuration, you conveniently know the ownership needed for your web files.
RUN mkdir -p /var/www/html/mywebsite && chown -R www-data:www-data /var/www/html/mywebsite
# copy the website folder int the container
COPY ./tools/mywebsite /var/www/html/mywebsite
# copy the configuration for Apache2
COPY ./conf/000-default.conf /etc/apache2/sites-available/000-default.conf
# running the apache2 in the foreground mode
# foreground mode : The foreground process will not allow you to use terminal unless the process is completed
# in this case if you need to access back to your terminal then you have to open a new terminal window or
# stop the running process or kill it.
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
A simple configuration for Apache2:
# The VirtualHost directive allows you to configure and use multiple sites located on the smae IP address
# for the *:80 is creating a virtual host for every request coming on the port 80
<VirtualHost *:80>
# if the host part of the HTTP request matches this name then allow the request
ServerName localhost
# the directory which apache2 looks for and serves web files from the requested URL
DocumentRoot /var/www/html/mywebsite/
# where Error log of apache stored
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
I found a template for the portfolio on the internet (I don’t like coding with HTML/CSS), I modified it for my needs.
Then I exposed it on port 80
The website section in docker-compose.yml file
You can connect to The Website at http://localhost:80
Resources
How To Configure the Apache Web Server on an Ubuntu or Debian VPS | DigitalOcean