Merge pull request #205 from YukiOta/ja-trans/8.13

translate 8.13
This commit is contained in:
YukiOta
2021-01-09 18:15:25 +09:00
committed by GitHub
2 changed files with 10 additions and 10 deletions

View File

@ -1223,13 +1223,13 @@ In addition, referring to an image tag means that the base image is subject to c
<br /><br /><br />
## ![✔] 8.13 Clean NODE_MODULE cache
## ![✔] 8.13 NODE_MODULE キャッシュをクリーンアップする
**TL;DR:** After installing dependencies in a container remove the local cache. It doesn't make any sense to duplicate the dependencies for faster future installs since there won't be any further installs - A Docker image is immutable. Using a single line of code tens of MB (typically 10-50% of the image size) are shaved off
**TL;DR:** コンテナに依存関係をインストールした後は、ローカルのキャッシュを削除してください。今後のインストールを高速化することを目的として依存関係を複製しても、意味はありません - Docker イメージは不変です。一行のコードで、数十 MB通常は画像サイズの 10~50%)を削ることができます。
**Otherwise:** The image that will get shipped to production will weigh 30% more due to files that will never get used
**さもないと:** 使用されないファイルが原因で、サイズが 3 割増のイメージがプロダクションにデプロイされることになります。
🔗 [**Read More: Clean NODE_MODULE cache**](/sections/docker/clean-cache.md)
🔗 [**さらに読む: NODE_MODULE キャッシュをクリーンアップする**](/sections/docker/clean-cache.japanese.md)
<br /><br /><br />

View File

@ -1,16 +1,16 @@
# Clean NODE_MODULE cache
# NODE_MODULE キャッシュをクリーンアップする
<br/><br/>
### One Paragraph Explainer
### 一段落説明
Node package managers, npm & Yarn, cache the installed packages locally so that future projects which need the same libraries won't need to fetch from a remote repository. Although this duplicates the packages and consumes more storage - it pays off in a local development environment that typically keeps installing the same packages. In a Docker container this storage increase is worthless since it installs the dependency only once. By removing this cache, using a single line of code, tens of MB are shaved from the image. While doing so, ensure that it doesn't exit with non-zero code and fail the CI build because of caching issues - This can be avoided by including the --force flag.
Node パッケージマネージャである npm Yarn は、同じライブラリを必要とする将来のプロジェクトがリモートリポジトリから取得する必要が無いように、インストールされたパッケージをローカルにキャッシュします。これはパッケージを複製し、より多くのストレージを消費しますが、一般的に同じパッケージをインストールし続けるローカルの開発環境においては効果的です。Docker コンテナでは、依存関係をインストールするのは一度だけなので、このストレージの増加には意味がありません。一行のコードを利用してこのキャッシュを削除することで、イメージから数十 MB を削ることができます。そうする間、non-zero code で中断し、CI のビルドに失敗しないようにしてください - これは --force フラグを含めることで回避できます。
*Please not that this is not relevant if you are using a multi-stage build as long as you don't install new packages in the last stage*
*マルチステージビルドを利用している場合は、最後のステージで新しいパッケージをインストールしない限り、このプラクティスは関係が無いことに注意してください*
<br/><br/>
### Code Example Clean cache
### コード例 - キャシュをクリーンアップする
<details>
<summary><strong>Dockerfile</strong></summary>
@ -21,7 +21,7 @@ WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci --production && npm cache clean --force
# The rest comes here
# 残りの部分がここに記述されます
```
</details>