Reputation: 177
I want to deploy Traefik using Portainer Git Repository Stack however it also needs a traefik.yml configuration file. I do not want to have to copy it from git and put it into a bind-mount location manually. This goes for any other image needing configuration as well.
Is there a way in which one or more configuration files can be copied from git as part of the automatic stack deployment?
I have seen some docker-compose files include containers for initial setups before although in a separate context. I can see this as perhaps being a workaround where a git checkout is done and then a file copy. Not sure how this should be done properly though.
An example docker-compose.yml file for Traefik
version: '3.8'
services:
traefik:
image: "traefik:latest"
container_name: "traefik"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- type: bind
# traefik.yml needs to be placed here
source: ~/docker/traefik/config
target: /etc/traefik
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock:ro
Upvotes: 1
Views: 492
Reputation: 31
Just ran into this myself so thought I'd provide answer, I did the last option. You could either:
Use "Relative Path Support" in Portainer BE (you can sign-up to get free 3 node business edition license), see: https://docs.portainer.io/advanced/relative-paths
OR
Add a service container to do git checkout into volume, see: https://github.com/portainer/portainer/issues/6390#issuecomment-1100954657
OR
Use an environment variable to point to full path, see: https://github.com/portainer/portainer/issues/6390#issuecomment-1142664730
Ex (copy paste from above reference):
services: node: image: node:alpine volumes: - ${PROJECT_PATH:-$PWD}:/app
This will fail because /app folder will be empty. But you can go into the Container -> Container details -> Labels and check the com.docker.compose.project.working_dir Get this value and set the PROJECT_PATH env var to it. Also you might need to prepend it with the full path to portainer Ex. com.docker.compose.project.working_dir = /data/compose/5 Portainer absolute path is /mnt/ssd-pool/apps/portainer so the PROJECT_PATH is /mnt/ssd-pool/apps/portainer/data/compose/5 Then you can Pull and redeploy Also docker-compose has default value $PWD that is for local development.
Upvotes: 0