Browse Source

Add dockerignore file to ignore node_modules folder while building docker image (#588)

#### What type of PR is this?

/kind optimization
/milestone 2.0

#### What this PR does / why we need it:

As I mentioned in the title, this PR mainly ignore the `node_modules` folder while copying current files into Docker daemon context. Because it is huge and unnecessary. Please see the size below:

```bash
--- /home/johnniang/workspaces/halo-dev/halo-admin ------------------------------------
  736.4 MiB S 388.8 MiB [###################] /node_modules
   12.2 MiB             [                   ] /.git
  892.0 KiB             [                   ] /packages
  616.0 KiB             [                   ] /src
  292.0 KiB             [                   ]  pnpm-lock.yaml
   48.0 KiB             [                   ] /cypress
   40.0 KiB             [                   ] /.github
   36.0 KiB             [                   ]  LICENSE
   20.0 KiB             [                   ] /.husky
   16.0 KiB             [                   ] /.changeset
   12.0 KiB             [                   ] /public
```

- Before

    ```bash
    Sending build context to Docker daemon  740MB
    Step 1/15 : FROM node:lts-alpine as build-stage
     ---> b0cbdedc1b9d
    Step 2/15 : ENV PNPM_VERSION 7.5.0
     ---> Using cache
     ---> 6184c581a0af
    Step 3/15 : RUN apk --no-cache add curl
     ---> Using cache
     ---> 74b030c17e7b
    Step 4/15 : RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
    ```

- After

    ```bash
    Sending build context to Docker daemon  12.59MB
    Step 1/15 : FROM node:lts-alpine as build-stage
     ---> b0cbdedc1b9d
    Step 2/15 : ENV PNPM_VERSION 7.5.0
     ---> Using cache
     ---> 6184c581a0af
    Step 3/15 : RUN apk --no-cache add curl
     ---> Using cache
     ---> 74b030c17e7b
    Step 4/15 : RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
    ```

#### Does this PR introduce a user-facing change?

```release-note
None
```
pull/589/head
John Niang 2 years ago committed by GitHub
parent
commit
5f8f8c6c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .dockerignore

1
.dockerignore

@ -0,0 +1 @@
**/node_modules
Loading…
Cancel
Save