Docker compose not using .env file correctly?

Feature(s) impacted

Calling docker compose in git action does not seem to use .env correctly when building container

Observed behavior

This might be a git actions issue but I’ll ask here anyway.

I’m copying all the production environment variables into the .env file (overwriting the dev ones) and uploading it to git. When I use the docker compose command in the git action to build the container I get no error but when I run it I get the error…

/usr/src/app/node_modules/@forestadmin/agent/dist/utils/options-validator.js:68
            throw new Error('options.envSecret is invalid. You can retrieve its value from ' +

However, I know it is reading the .env file because if I deliberately rename of invalidate it, I get an error saying the APPLICATION_PORT value is missing. Have you come across this behaviour before? If I use the same docker compose command in a terminal session it appears to work correctly.

Expected behavior

A valid error free container

Failure Logs

See above

Context

n/a

Hello @mike.n :wave: ,

Can you give me more informations about the git action you use ?

Kind regards,

Florian

This is the section of the yaml in question

- name: Build, tag, and push image to Amazon ECR
  id: build-image
  env:
    ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
    IMAGE_TAG: ${{ env.ECS_APP_NAME }}
  run: |
    # Build a docker container and push it to ECR so that it can be deployed to EC2.
    # docker compose -f docker-compose.yml create
    # docker tag $IMAGE_TAG:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
    # docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
    echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

Some more to add here. If I build locally using docker compose -f docker-compose.yml create I get a container which includes the various values from the .env file (I can see them on the Inspect tab in docker desktop). However, when I run the container, it says it can’t read the options.envSecret as shown above.

However, if I deliberately break the .env file, the values aren’t there. It is almost as if it isn’t reading the Environment values in the container. When I’ve used a container in ECS, I push the values in via the task definition and it works just fine.

Can you send me your entire file docker compose and the command you use to run it ?

That should be…

run: |
# Build a docker container and push it to ECR so that it can be deployed to EC2.
docker compose -f docker-compose.yml create
docker tag $IMAGE_TAG:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo “image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG” >> $GITHUB_OUTPUT

Thank you i will try to reproduce it :pray: