aws-elastic-beanstalk-cli icon indicating copy to clipboard operation
aws-elastic-beanstalk-cli copied to clipboard

.ebignore doesn't strictly follow .gitignore syntax

Open ZYinMD opened this issue 2 years ago • 6 comments

Description

In .gitignore (doc), /* means "everything, including folders, in the root path relative to the .gitignore file".

This is a good starting point to construct a "whitelist" where you use ! to include only the files you want.

However, it seems /* in .ebignore won't ignore folders.

Steps to reproduce

Create a folder structure like this:

root
  |--.git/
  |--node_modules/
  |    |--deps/
  |    |--useless-dev-deps/
  |--some-other-folder/
  |    |--other-folder-content.txt
  |--server.js
  |--package.json
  |--README.md
  |--.ebignore

Then construct a whitelist with .ebignore:

# start off by ignoring everything
\*

# other than these 2 files, nothing else is required for this deployment to work 
!server.js
!package.json

Then deploy with eb deploy, then inspect the zip file in eb console.

Observed result

  1. README.md is successfully ignored
  2. .git, node_modules, and some-other-folder are included in the zip.

Expected result

If .ebignore works the same way as .gitignore, .git, node_modules, and some-other-folder shouldn't be zipped.

(irrelevant note: Google App Engine has an equivalent .gcloudignore file, which behaves consistently with this "expected result")

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Win10
  2. EBCLI version: 3.20.3 (Python 3.9.6)

ZYinMD avatar May 10 '22 18:05 ZYinMD

There's actually some additional bizarre behavior regarding node_modules, which I can describe in another issue.

ZYinMD avatar May 10 '22 21:05 ZYinMD

I am also encountering this behavior:

# .ebignore

...
/storage/*
!/storage/.keep
...

Results in:

$ eb deploy -v
INFO:   +adding: ./storage/v6/oc/v6oc5ko1eembqt1u2mr25mii4iue
INFO:  +adding: ./storage/9y/xi/
INFO:   +adding: ./storage/9y/xi/9yxi0znpqwrgkdksewg4vhl1bsek
INFO:  +adding: ./storage/92/1d/
INFO:   +adding: ./storage/92/1d/921d0jwhly08qf1s0w0m5zsqsc62
INFO:  +adding: ./storage/sb/9p/
INFO:   +adding: ./storage/sb/9p/sb9pq7tlrfj0okgkx9p18ify2vjx
INFO:  +adding: ./storage/u7/yp/
INFO:   +adding: ./storage/u7/yp/u7yp9aw60q2x3u3gstmbsm6regdp
INFO:  +adding: ./storage/z3/xb/

But

# .ebignore

...
/storage
...

results in:

INFO:   -skipping: ./storage/v6/oc/v6oc5ko1eembqt1u2mr25mii4iue
INFO:   -skipping: ./storage/9y/xi/9yxi0znpqwrgkdksewg4vhl1bsek
INFO:   -skipping: ./storage/92/1d/921d0jwhly08qf1s0w0m5zsqsc62
INFO:   -skipping: ./storage/sb/9p/sb9pq7tlrfj0okgkx9p18ify2vjx
INFO:   -skipping: ./storage/u7/yp/u7yp9aw60q2x3u3gstmbsm6regdp
INFO:   -skipping: ./storage/z3/xb/z3xbickjxkyvjoqwk8w63wfgmsw1
INFO:   -skipping: ./storage/3e/89/3e89reffzp4sqb1xmiix6jj1qmrl
INFO:   -skipping: ./storage/se/84/se84y8itgkufezud31r7y3ccaz95
INFO:   -skipping: ./storage/yw/67/yw67vz7yrxioq2p08alxft9s9z4e
INFO:   -skipping: ./storage/6f/6c/6f6c7d3xbh1tr1vpj6cgz11v1wj8
INFO:   -skipping: ./storage/sw/z7/swz7royzygltiea1z0j3gg2nxd21
INFO:   -skipping: ./storage/9b/vu/9bvutzmdpg46crtct1dsakp6igpj

littleforest avatar Jul 22 '22 16:07 littleforest

I am having this exact issue, but I have permission issues on some files that should be ignored. The folder shouldn't even be entered if ignored

Parker-Bergen avatar Dec 01 '22 20:12 Parker-Bergen

Hi @ZYinMD are you still facing the issue ? I was able to do eb deploy and it seemed to work as expected . My folder structure :

root1]$ ls -la 
total 32
drwxr-xr-x 6  amazon 4096 Oct 25 22:21 .
drwxr-xr-x 4  amazon 4096 Oct 25 22:17 ..
-rw-r--r-- 1 amazon   15 Oct 25 22:21 .ebignore
drwxr-xr-x 2  amazon 4096 Oct 25 22:22 .elasticbeanstalk
drwxr-xr-x 7  amazon 4096 Oct 25 22:22 .git
-rw-r--r-- 1  amazon  108 Oct 25 22:20 .gitignore
drwxr-xr-x 4  amazon 4096 Oct 25 22:18 node_modules
-rw-r--r-- 1  amazon    0 Oct 25 22:18 package.json
-rw-r--r-- 1  amazon    0 Oct 25 22:18 README.md
-rw-r--r-- 1  amazon    0 Oct 25 22:18 server.js
drwxr-xr-x 2  amazon 4096 Oct 25 22:18 some-other-folder

.ebignore looks like :

/*

!server.js

This is part of the eb deploy --verbose output , which shows that it is skipping everything except server.js as mentioned in the .ebignore file

eb deploy --verbose
INFO: Deploying code to roottest in region us-east-1
INFO: Getting version label from git with git-describe
Creating application version archive "app-364d-231025_222737283834".
INFO: Found .ebignore, using system zip.
INFO: Zipping up folder at location: /local/home/test114/root1
INFO:   -skipping: ./.ebignore
INFO:   -skipping: ./README.md
INFO:   -skipping: ./package.json
INFO:  +adding: .//
INFO:   +adding: ./server.js
INFO:   -skipping: ./.gitignore
INFO:   -skipping: ./.elasticbeanstalk
INFO:   -skipping: ./.elasticbeanstalk/app_versions
INFO:   -skipping: ./some-other-folder/other-folder-content.txt
INFO:   -skipping: ./.git/HEAD
INFO:   -skipping: ./.git/config
INFO:   -skipping: ./.git/description
INFO:   -skipping: ./.git/COMMIT_EDITMSG
INFO:   -skipping: ./.git/index
INFO:   -skipping: ./.git/logs/HEAD
INFO:   -skipping: ./.git/logs/refs/heads/master
INFO:   -skipping: ./.git/info/exclude
INFO:   -skipping: ./.git/hooks/applypatch-msg.sample
INFO:   -skipping: ./.git/hooks/pre-push.sample
INFO:   -skipping: ./.git/hooks/pre-rebase.sample
INFO:   -skipping: ./.git/hooks/pre-commit.sample
INFO:   -skipping: ./.git/hooks/pre-merge-commit.sample
INFO:   -skipping: ./.git/hooks/fsmonitor-watchman.sample
INFO:   -skipping: ./.git/hooks/update.sample
INFO:   -skipping: ./.git/hooks/sendemail-validate.sample
INFO:   -skipping: ./.git/hooks/pre-receive.sample
INFO:   -skipping: ./.git/hooks/pre-applypatch.sample
INFO:   -skipping: ./.git/hooks/prepare-commit-msg.sample
INFO:   -skipping: ./.git/hooks/push-to-checkout.sample
INFO:   -skipping: ./.git/hooks/commit-msg.sample

zipinfo on the uploaded application file is as follows :

zipinfo app-364d-231025_222211818947
Archive:  app-364d-231025_222211818947.zip
Zip file size: 198 bytes, number of entries: 2
drwxr-xr-x  2.0 unx        0 b- stor 23-Oct-25 22:21 ./
-rw-r--r--  2.0 unx        0 b- defN 23-Oct-25 22:18 server.js

OS: Amazon Linux 2 EB-CLI Version : 3.20.10 Git version :2.42.0

Also , there seems to be an issue with Pathspec in windows https://github.com/cpburnz/python-pathspec/issues/81

NihalM99 avatar Oct 25 '23 22:10 NihalM99

Hi @NihalM99 , I'm not currently using eb (1.5 years after filing this issue), sorry I don't have an answer from personal experience, but I hope it's already fixed as you've found!

ZYinMD avatar Oct 26 '23 01:10 ZYinMD

@NihalM99 I see you referenced bug cpburnz/python-pathspec#81. This is now fixed in the v0.12.0 release of pathspec.

cpburnz avatar Dec 09 '23 23:12 cpburnz