From c1df934c552115011b05c2217d16c71205b857c9 Mon Sep 17 00:00:00 2001 From: stanclai Date: Sat, 2 Mar 2019 22:33:16 +0100 Subject: [PATCH] perf: Reduce docker image (#1064) * Add .dockerignore file to clean image building area * Optimize docker image build --- .dockerignore | 18 ++++++++++++++++++ Dockerfile | 16 +++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..78e905a2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +.git +BREAKING_CHANGES.md +CONTRIBUTING.md +docs +README.md +tests +.DS_Store +/node_modules +/__sapper__ +/mastodon +/mastodon.log +/src/template.html +/static/*.css +/static/robots.txt +/static/inline-script.js.map +/static/emoji-mart-all.json +/src/inline-script/checksum.js +yarn-error.log diff --git a/Dockerfile b/Dockerfile index c2367c8c..1188f852 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,15 +6,17 @@ WORKDIR /app ADD . /app # Install updates and NodeJS+Dependencies -RUN apk update && apk upgrade -RUN apk add nodejs npm git python build-base clang - +RUN apk add --update --no-cache --virtual build-dependencies git python build-base clang \ +# Install updates and NodeJS+Dependencies + && apk add --update --no-cache nodejs npm \ # Install yarn -RUN npm i yarn -g - + && npm i yarn -g \ # Install Pinafore -RUN yarn --pure-lockfile -RUN yarn build + && yarn --pure-lockfile \ + && yarn build \ + && rm -rf ./src \ +# Cleanup + && apk del build-dependencies # Expose port 4002 EXPOSE 4002