EN VI

Adding Smarty Template to Docker Compose File?

2024-03-09 23:00:27
How to Adding Smarty Template to Docker Compose File?

I am very new to this, but trying to learn Docker. I have my apache server running from the below Compose file and now I want to install Smarty template tool.

I am trying to get a portable container that I can move between machines, so I think I need to put it all in the same compose file (but I am likely looking at this wrong).

Smarty say to use "compose require smarty/smarty" but I have no idea (yet) how to do this :-)

Can anyone help me?

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: {}

Solution:

To install Smarty in your Docker container running Apache, you can follow these steps:

Update your Docker Compose file to include a new service for installing Smarty. You can use a separate service for this purpose.

Add a new service in your Docker Compose file like this:

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: {}

Make sure to export all the variables properly htmlpath,uid,pwd etc

Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login