简体   繁体   English

在 Ubuntu 18.04 上托管使用 docker 构建的 web 应用程序

[英]Hosting web application built with docker on Ubuntu 18.04

I have a web application built with Codeigniter. I recently implemented Docker in the application on the localhost.我有一个用 Codeigniter 构建的 web 应用程序。我最近在本地主机上的应用程序中实现了 Docker。 Now how do I deploy modified application and the docker containers on the server.现在如何在服务器上部署修改后的应用程序和 docker 容器。

I have provided my docker-compose file below.我在下面提供了我的 docker-compose 文件。

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.部署过程与我们在没有 docker 的情况下部署 web 应用程序或网站时遵循的过程没有什么不同。只有以下更改是额外的,需要在服务器上完成。

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然后对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 inte.net with a domain name.您应该能够使用域名从 inte.net 访问您的网站或 web 应用程序。 You can also add https with letsencrypt and the steps are the same.也可以用letsencrypt添加https,步骤相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM