I have a web application built with Codeigniter. I recently implemented Docker in the application on the localhost. Now how do I deploy modified application and the docker containers on the server.
I have provided my docker-compose file below.
version: '3.3'
services:
myapp:
image: docker.io/bitnami/codeigniter:3
container_name: app-backend
ports:
- '8000:8000'
volumes:
- '.:/app'
depends_on:
- mariadb
mariadb:
image: docker.io/bitnami/mariadb:10.3
container_name: app-marriadb
volumes:
- app_dbdata:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: app_db
ports:
- '3307:3306'
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
app_dbdata:
The process of deploying is not different from what we follow while deploying a web app or website without docker. Only the following changes are additional which needs to be done on the server.
I changed the virtual host as shown below.
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www
ErrorLog logs/docker.example.com_error.log
CustomLog logs/docker.example.com_access.log combined
ProxyPreserveHost On
ProxyRequests off
<Location />
ProxyPass http://localhost:8000/
ProxyPassReverse http://localhost:8000/
Order allow,deny
Allow from all
</Location>
</VirtualHost>
And then made the following changes to Apache
$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
$ systemctl restart apache2
You should have be able to access your website or web app from the internet with a domain name. You can also add https with letsencrypt and the steps are the same.