Portainer fails to create stack.env file when deploying stack from git #10902
Description
Before you start please confirm the following.
- Yes, I've searched similar issues on GitHub.
- Yes, I've checked whether this issue is covered in the Portainer documentation or knowledge base.
Problem Description
It seems Portainer isn't creating the stack.env file when I enter environment variables into the UI when pulling a docker-compose file from a git repo. This causes the stack to fail to deploy as it shows an error message about being unable to find the stack.env file.
My docker-compose file contains the following:
env_file:
- stack.env
According to the documentation found here adding the above to the docker-compose file should map any environment variables entered in the UI to the container.
Expected Behavior
The stack to be able to be deployed as normal and any environment variables that are entered in the UI to be mapped to the container.
Actual Behavior
An error is encounter saying that it is unable to deploy the stack as the stack.env file is not found:
Steps to Reproduce
- In Portainer click on Stacks in the sidebar
- Give the stack a name.
- Click the Repository build method
- Enter the details of said repository (repository used in this instance: https://github.com/dandyrow/homelab)
- Enter path of the docker-compose file which has the env_file tag set to stack.env (in this instance the path was docker-compose/traefik/docker-compose.yml)
- Enter the environment variables (CF_DNS_API_TOKEN for my case)
- Click Deploy to stack
- The deploy fails with the above error.
Portainer logs or screenshots
This is what I have entered for my environment variables within the UI.
Portainer version
2.19.4
Portainer Edition
Community Edition (CE)
Platform and Version
Podman 4.8.2
OS and Architecture
Arch Linux
Browser
LibreWolf 119.0-7
What command did you use to deploy Portainer?
I used an ansible playbook I created which is in the ansible folder of the above repo. The step which deployed portainer looked as follows:
- name: Run portainer container
containers.podman.podman_container:
name: portainer
image: docker.io/portainer/portainer-ce
ports:
- 8000:8000
- 9443:9443
volume:
- "{{ lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR') }}\
/podman/podman.sock:/var/run/docker.sock"
- portainer_data:/data
restart_policy: always
state: started
Additional Information
Stack.env works when uploading the docker compose file manually rather than using Git