Skip to content

Portainer fails to create stack.env file when deploying stack from git #10902

Open
@dandyrow

Description

Before you start please confirm the following.

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:

Screenshot from 2023-12-30 16-14-30

Steps to Reproduce

  1. In Portainer click on Stacks in the sidebar
  2. Give the stack a name.
  3. Click the Repository build method
  4. Enter the details of said repository (repository used in this instance: https://github.com/dandyrow/homelab)
  5. 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)
  6. Enter the environment variables (CF_DNS_API_TOKEN for my case)
  7. Click Deploy to stack
  8. The deploy fails with the above error.

Portainer logs or screenshots

image

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions