Skip to content

Add .git to the .dockerignore config #221

@dannystaple

Description

@dannystaple

The .git folder brings a large context with it, slowing the containers.
Add this into the dockerignore config.
Test with a docker compose run shell (which will need to be exited as it starts a cli), and add the size of the new docker context.

For comparison:

$ docker compose run shell
[+] Creating 1/1
 ✔ Network orionrobotsgithubio_default  Created                                                                                                                                                                                                            0.1s 
[+] Building 100.6s (14/14) FINISHED                                                                                                                                                                                                                            
 => [internal] load local bake definitions                                                                                                                                                                                                                 0.0s
 => => reading from stdin 409B                                                                                                                                                                                                                             0.0s
 => [internal] load build definition from serve.Dockerfile                                                                                                                                                                                                 0.0s
 => => transferring dockerfile: 659B                                                                                                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/node:24-bullseye                                                                                                                                                                                        1.1s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                          0.0s
 => => transferring context: 210B                                                                                                                                                                                                                          0.0s
 => [base 1/5] FROM docker.io/library/node:24-bullseye@sha256:f285a3fcdab672936c13241815434c3c77e4b0aec936bf4ea058b77e8c4ba6ef                                                                                                                            46.5s
 => => resolve docker.io/library/node:24-bullseye@sha256:f285a3fcdab672936c13241815434c3c77e4b0aec936bf4ea058b77e8c4ba6ef                                                                                                                                  0.0s
 => => sha256:f285a3fcdab672936c13241815434c3c77e4b0aec936bf4ea058b77e8c4ba6ef 2.64kB / 2.64kB                                                                                                                                                             0.0s
 => => sha256:e1f5b88fdea8054df47377605922b1499193661d4136bc9b0fa8c2e38f75e091 6.62kB / 6.62kB                                                                                                                                                             0.0s
 => => sha256:54d1704eb717ce17ad2843f567b5defc32883042e6e9f97e2bcf2ce3c282677b 54.76MB / 54.76MB                                                                                                                                                           2.2s
 => => sha256:c30fd39f8587979af2ce92647c4ce6fc04921556b6088d425d3bb10e8d40b0de 2.50kB / 2.50kB                                                                                                                                                             0.0s
 => => sha256:632ef5283d0fcf0e3a19d6c5dbcc294922d142b506d2ab494fb73004518cdc31 53.75MB / 53.75MB                                                                                                                                                           2.2s
 => => sha256:2be42d221bda6286090b1656c911554463aed2c0d506c236e16250de9b9e4667 15.77MB / 15.77MB                                                                                                                                                           2.2s
 => => sha256:f0f51ee5c79e1ef5812268320c854e2eaf0bb5f4e2cf2a7974448200d36854de 197.14MB / 197.14MB                                                                                                                                                         7.8s
 => => sha256:08ce17e86c6482205c17e6f94ab950eeee2a7ec94698c1c0f79b738685f9c6b3 4.08kB / 4.08kB                                                                                                                                                             6.1s
 => => extracting sha256:632ef5283d0fcf0e3a19d6c5dbcc294922d142b506d2ab494fb73004518cdc31                                                                                                                                                                  8.9s
 => => sha256:c1cbd52b449923024edcce33e4c6890f1a264d51eda15b27f4ead08148116d21 58.55MB / 58.55MB                                                                                                                                                           3.5s
 => => sha256:67c38ffb6014980ed5124162ef7b29f02330dc797058c66031071a8c470c9f92 1.25MB / 1.25MB                                                                                                                                                             7.8s
 => => sha256:7fa8702aed5ae6f922bb83ff6fd4c2dc5d76c8f157821586fc3f15fdfc9a2dec 448B / 448B                                                                                                                                                                 7.8s
 => => extracting sha256:2be42d221bda6286090b1656c911554463aed2c0d506c236e16250de9b9e4667                                                                                                                                                                  2.9s
 => => extracting sha256:54d1704eb717ce17ad2843f567b5defc32883042e6e9f97e2bcf2ce3c282677b                                                                                                                                                                  4.2s
 => => extracting sha256:f0f51ee5c79e1ef5812268320c854e2eaf0bb5f4e2cf2a7974448200d36854de                                                                                                                                                                  9.6s
 => => extracting sha256:08ce17e86c6482205c17e6f94ab950eeee2a7ec94698c1c0f79b738685f9c6b3                                                                                                                                                                  0.0s
 => => extracting sha256:c1cbd52b449923024edcce33e4c6890f1a264d51eda15b27f4ead08148116d21                                                                                                                                                                  3.2s
 => => extracting sha256:67c38ffb6014980ed5124162ef7b29f02330dc797058c66031071a8c470c9f92                                                                                                                                                                  0.1s
 => => extracting sha256:7fa8702aed5ae6f922bb83ff6fd4c2dc5d76c8f157821586fc3f15fdfc9a2dec                                                                                                                                                                  0.0s
 => [internal] load build context                                                                                                                                                                                                                         25.8s
 => => transferring context: 1.09GB                                                                                                                                                                                                                       25.8s
 => [base 2/5] WORKDIR /app/src                                                                                                                                                                                                                            0.0s
 => [base 3/5] COPY package.json package-lock.json ./                                                                                                                                                                                                      0.0s
 => [base 4/5] RUN npm install                                                                                                                                                                                                                            10.8s
 => [base 5/5] COPY . /app/src                                                                                                                                                                                                                            21.2s
 => [debug 1/1] RUN apt-get update && apt-get install -y     less     iputils-ping     dnsutils                                                                                                                                                            5.4s
 => exporting to image                                                                                                                                                                                                                                    15.1s
 => => exporting layers                                                                                                                                                                                                                                   15.1s
 => => writing image sha256:f55077d5bc7a206d5e36b0126dbce3b2cabeb0a79992aeb702181df155ff6815                                                                                                                                                               0.0s
 => => naming to docker.io/library/orionrobotsgithubio-shell                                                                                                                                                                                               0.0s
 => resolving provenance for metadata file        

This should save time and reduce memory usage when testing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions