将 Smarty 模板添加到 Docker Compose 文件中?

问题描述 投票:0回答:1

我对此很陌生,但正在尝试学习 Docker。我的 apache 服务器从下面的 Compose 文件运行,现在我想安装 Smarty 模板工具。

我正在尝试获得一个可以在机器之间移动的便携式容器,所以我认为我需要将其全部放在同一个撰写文件中(但我可能看错了)。

Smarty 说使用“compose require smarty/smarty”,但我(尚)不知道如何做到这一点:-)

有人可以帮助我吗?

version: "3"
services:
  webserver:
    image: php:apache
    ports:
      - 32001:80
    volumes:
      - volHTML:/var/www/html
    restart: always
volumes:
  volHTML:
    driver: local
    driver_opts:
      type: cifs
      device: ${htmlpath}
      o: username=${uid},password=${pwd},uid=1000,gid=1000
networks: {}
docker docker-compose smarty
1个回答
0
投票

要在运行 Apache 的 Docker 容器中安装 Smarty,可以按照以下步骤操作:

更新您的 Docker Compose 文件以包含用于安装 Smarty 的新服务。您可以为此目的使用单独的服务。

在 Docker Compose 文件中添加新服务,如下所示:

version: "3"
services:
  webserver:
    image: php:apache
    ports:
      - 32001:80
    volumes:
      - volHTML:/var/www/html
    restart: always
  smarty_installer:
    image: composer
    volumes:
      - volHTML:/var/www/html
    command: require smarty/smarty

volumes:
  volHTML:
    driver: local
    driver_opts:
      type: cifs
      device: ${htmlpath}
      o: username=${uid},password=${pwd},uid=1000,gid=1000
networks: {}

确保正确导出所有变量

htmlpath,uid,pwd

© www.soinside.com 2019 - 2024. All rights reserved.