Skip to content

Commit

Permalink
feat: smaller image (DIYgod#4278)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx authored Mar 19, 2020
1 parent 623056e commit 77ccb13
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
15 changes: 14 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ Dockerfile*
docker-compose*
.dockerignore
.gitignore
README.md
LICENSE
.vscode
.github
assets
coverage
docs
test
.codecov.yml
.eslint*
.prettier*
.(yarn|npm|nvm)rc
*.md
process.json
app.json
.travis.yml

#git but keep the git commit hash
.git/logs
.git/objects
.git/index
.git/info
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN apt-get update && apt-get install -yq libgconf-2-4 apt-transport-https git d

WORKDIR /app

COPY package.json /app
COPY package.json clean-nm.sh /app/

RUN if [ "$USE_CHINA_NPM_REGISTRY" = 1 ]; then \
echo 'use npm mirror'; npm config set registry https://registry.npm.taobao.org; \
Expand All @@ -33,10 +33,10 @@ RUN if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ]; then \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge --auto-remove -y wget\
&& rm -rf /src/*.deb \
&& npm install --production; \
&& npm install --production && sh ./clean-nm.sh;\
else \
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && \
npm install --production; \
npm install --production && sh ./clean-nm.sh;\
fi;

COPY . /app
Expand Down
4 changes: 4 additions & 0 deletions clean-nm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
find ./node_modules -type f |grep -E "(.idea|.vscode|benchmark.js|.eslintrc.js|changelog|AUTHORS|license|LICENSE|LICENCE|.travis.yml|.eslintrc.json|.eslintrc.yml|Makefile|.npmignore|.DS_Store|.jshintrc|.eslintrc.BSD|.editorconfig|tsconfig.json|.coveralls.yml|appveyor.yml|.gitattributes|.eslintignore|.eslintrc|.eslintignore.BSD|.babelrc)" |xargs rm -rf;
find node_modules -type f | grep -E "\.(md|mdon|markdown|log|ts|swp|jst|coffee|txt|BSD|m?js.map)$" | xargs rm -f;
find node_modules -type d | grep -E "(examples|example|.githubs|@types)" | xargs rm -rf;

0 comments on commit 77ccb13

Please sign in to comment.