Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env_file field in Logstash making impossible to use untouched Laradock project structure #3146

Closed
DJviolin opened this issue Feb 12, 2022 · 16 comments

Comments

@DJviolin
Copy link

DJviolin commented Feb 12, 2022

Description:

I try to achieve the following project structure, where I keep Laradock in an untouched git submodule:

/my-project-folder
    /laradock
    /src
    /wordpress
    .env
    docker-compose.override.yml

My docker-compose.override.yml looks like this:

version: '3.5'

services:

### NGINX Server #########################################
    nginx:
      volumes:
        - '${NGINX_GLOBAL_PATH}:/etc/nginx/global'

### Logstash ##############################################
    logstash:
      env_file: ../.env

Lines in .env:

APP_CODE_PATH_HOST=../wordpress
APP_CODE_PATH_CONTAINER=/var/www/wordpress
DATA_PATH_HOST=../.laradock/data
PHP_VERSION=8.1
NGINX_HOST_LOG_PATH=../.laradock/logs/nginx/
NGINX_SITES_PATH=../src/nginx/sites/
NGINX_SSL_PATH=../.laradock/ssl
NGINX_GLOBAL_PATH=../src/nginx/global/
ADM_DEFAULT_SERVER=laradock-mariadb-1

I run Docker Compose with this command from /my-project-folder:

PS docker-compose --env-file .env -f laradock/docker-compose.yml -f docker-compose.override.yml up -d nginx mariadb adminer

I'm getting the following error, if I not deleting env_file: field from Laradock's docker-compose.yml:

open C:\my-project-folder\laradock\.env: The specified file cannot be found.

Expected Behavior:

Is there any particular reason why env_file: presented in docker-compose.yml explicitly? If it wasn't there, it would be much easier to create more delicate deployments to use Laradock as an untouched submodule.

I think the reason why env_file: in docker-compose.override.yml doesn't replace the field in laradock/docker-compose.yml, because simply extending the array with the new value:

env_file:
    - .env
    - ../.env

Context information:

Output of git rev-parse HEAD

01ab8c7d1e12f7ed7d6c80651f396ce5661d2583

Output of docker version

Client:
 Cloud integration: v1.0.22
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:44:07 2021
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.5.0 (74594)
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker-compose version

Docker Compose version v2.2.3

System info: Mac, Windows or Linux. Include which disto/version

PS systeminfo
OS Name:                   Microsoft Windows 11 Pro
OS Version:                10.0.22000 N/A Build 22000
@stale
Copy link

stale bot commented Jun 11, 2022

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Jun 11, 2022
@DJviolin
Copy link
Author

Stalebot is the most useful invention in human programmer's history.

@stale stale bot removed the Stale label Jun 19, 2022
@stale
Copy link

stale bot commented Sep 20, 2022

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Sep 20, 2022
@DJviolin
Copy link
Author

Okay stale bot, I will let you close this issue.

@stale stale bot removed the Stale label Sep 21, 2022
@stale
Copy link

stale bot commented Dec 24, 2022

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Dec 24, 2022
@DJviolin
Copy link
Author

Okay stale bot, I will let you close this issue.

@zhushaolong
Copy link
Contributor

You should look at the relationship between the. env file and the Docker Compose instead of associating it with the logstash. --- From Baidu Translation.

@DJviolin
Copy link
Author

Referencing the entire .env file instead of the needed environment variables still a bad practice.

@zhushaolong
Copy link
Contributor

zhushaolong commented Dec 27, 2022

Let me show you:
The directory structure is as follows:

├── .env
├── docker-compose.yml
└── logstash
    ├── Dockerfile
    ├── config
    │   └── logstash.yml
    └── pipeline
        └── .gitkeep

4 directories, 3 files

The files in the logstash folder are from the laradock logstash folder.

.env file content:
The contents of the .env file are from the laradock .env file.

### ELK Stack ##################################################
ELK_VERSION=7.9.1

docker-compose.yml file content:
The contents of the docker-compose.yml file are from the laradock docker-compose.yml file

logstash:
    build:
        context: ./logstash
        args:
            - ELK_VERSION=${ELK_VERSION}
    volumes:
        - './logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml'
        - './logstash/pipeline:/usr/share/logstash/pipeline'
    ports:
        - '5001:5001'
    environment:
        LS_JAVA_OPTS: '-Xmx1g -Xms1g'
    env_file:
        - .env
    networks:
        - frontend
        - backend
    depends_on:
        - elasticsearch

You are welcome to try.

@zhushaolong
Copy link
Contributor

zhushaolong commented Dec 27, 2022

Referencing the entire .env file instead of the needed environment variables still a bad practice.

Please understand the function of the .env file.
https://docs.docker.com/compose/environment-variables/

The .env file is not required for logstash.

@DJviolin
Copy link
Author

The .env file is not required for logstash.

Thank You for clarifying my issue! Removing it from Logstash configuration will make the entire Laradock configuration more easily adopted for delicate project structures.

@zhushaolong
Copy link
Contributor

zhushaolong commented Dec 28, 2022

The .env file is not required for logstash.

Thank You for clarifying my issue! Removing it from Logstash configuration will make the entire Laradock configuration more easily adopted for delicate project structures.

Yes, if you only need logstash, you can directly modify ${ELK_VERSION} in docker-compose. yml.

@stale stale bot removed Stale labels Dec 28, 2022
@stale
Copy link

stale bot commented Apr 2, 2023

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Apr 2, 2023
@DJviolin
Copy link
Author

DJviolin commented Apr 2, 2023

I will wait until stalebot become sentient.

@stale
Copy link

stale bot commented May 21, 2023

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed May 21, 2023
@DJviolin
Copy link
Author

I will wait until stalebot become sentient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants