8000 dockerize vuejs appを翻訳 (#1126) · vuejs-jp-bot/jp.vuejs.org@f8c4e2e · GitHub
[go: up one dir, main page]

Skip to content

Commit f8c4e2e

Browse files
resesshpotato4d
authored andcommitted
dockerize vuejs appを翻訳 (vuejs#1126)
* dockerize vuejs appを翻訳 * 代替案->代替パターン fix vuejs#1126 (comment) * multi stageのコメント行をわかりやすく fix vuejs#1126 (comment) * フォルダを作成->フォルダを指定 fix vuejs#1126 (comment) * if availableを修正 fix vuejs#1126 (comment) * 好ましい理由->もっともな理由 fix vuejs#1126 (comment) * とても好ましい理由->とてももっともな理由 fix vuejs#1126 (comment) * マイクロサービスアーキテクチャの文の順序を調整 fix vuejs#1126 (comment) * fix typo (強力->協力) fix vuejs#1126 (comment) * では無い->ではない fix vuejs#1126 (comment)
1 parent 9e428c5 commit f8c4e2e

File tree

1 file changed

+50
-48
lines changed

1 file changed

+50
-48
lines changed
Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,136 @@
11
---
2-
title: Dockerize Vue.js App
2+
title: Vue.js アプリケーションを Docker 化する
33
type: cookbook
4+
updated: 2018-07-25
45
order: 13
56
---
67

7-
## Simple Example
8+
## 簡単な例
89

9-
So you built your first Vue.js app using the amazing [Vue.js webpack template](https://github.com/vuejs-templates/webpack) and now you really want to show off with your colleagues by demonstrating that you can also run it in a Docker container.
10+
あなたははじめての Vue.js アプリケーションを素晴らしい [Vue.js webpack テンプレート](https://github.com/vuejs-templates/webpack) を利用して作成し、Docker コンテナで実行もできることを同僚に披露したいと思っています。
1011

11-
Let's start by creating a `Dockerfile` in the root folder of our project:
12+
ではプロジェクトルートに `Dockerfile` を作成しましょう:
1213

1314
```docker
1415
FROM node:9.11.1-alpine
1516
16-
# install simple http server for serving static content
17+
# 静的コンテンツを配信するシンプルな http サーバをインストールする
1718
RUN npm install -g http-server
1819
19-
# make the 'app' folder the current working directory
20+
# カレントワーキングディレクトリとして 'app' フォルダを指定する
2021
WORKDIR /app
2122
22-
# copy both 'package.json' and 'package-lock.json' (if available)
23+
# `package.json` と `package-lock.json` (あれば)を両方コピーする
2324
COPY package*.json ./
2425
25-
# install project dependencies
26+
# プロジェクトの依存ライブラリをインストールする
2627
RUN npm install
2728
28-
# copy project files and folders to the current working directory (i.e. 'app' folder)
29+
# カレントワーキングディレクトリ(つまり 'app' フォルダ)にプロジェクトのファイルやフォルダをコピーする
2930
COPY . .
3031
31-
# build app for production with minification
32+
# 本番向けに圧縮しながらアプリケーションをビルドする
3233
RUN npm run build
3334
3435
EXPOSE 8080
3536
CMD [ "http-server", "dist" ]
3637
```
3738

38-
It may seem reduntant to first copy `package.json` and `package-lock.json` and then all project files and folders in two separate steps but there is actually [a very good reason for that](http://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/) (spoiler: it allows us to take advantage of cached Docker layers).
39+
はじめに `package.json` `package-lock.json` をコピーし、次にプロジェクトの全てのファイルとフォルダをコピーするという2つに別れたステップは冗長に見えるかもしれませんが、実際には [とてももっともな理由](http://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/) があります。(ネタばれ: これによってキャッシュされた Docker レイヤーを活用できます)
3940

40-
Now let's build the Docker image of our Vue.js app:
41+
では Vue.js アプリケーションの Docker イメージをビルドしましょう:
4142

4243
```bash
4344
docker build -t vuejs-cookbook/dockerize-vuejs-app .
4445
```
4546

46-
Finally, let's run our Vue.js app in a Docker container:
47+
最後に、 Vue.js アプリケーションを Docker コンテナで実行しましょう:
4748

4849
```bash
4950
docker run -it -p 8080:8080 --rm --name dockerize-vuejs-app-1 vuejs-cookbook/dockerize-vuejs-app
5051
```
5152

52-
We should be able to access our Vue.js app on `localhost:8080`.
53+
`localhost:8080` で Vue.js アプリケーションにアクセスができるでしょう。
5354

54-
## Real-World Example
55+
## 現実の例
5556

56-
In the previous example, we used a simple, zero-configuration command-line [http server](https://github.com/indexzero/http-server) to serve our Vue.js app which is perfectly ok for quick prototyping and _may_ even be ok for simple production scenarios. After all, the documentation says:
57+
上述の例では、シンプルで設定の無いコマンドラインの [http server](https://github.com/indexzero/http-server) を使って、素早いプロトタイピング完璧で、シンプルな本番のシナリオに良い _かもしれない_ Vue.js アプリケーションを配信しました。とにかく、そのドキュメントではこう言っています:
5758

58-
> It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.
59+
> 本番環境で使うには十分強力ですが、テスト、ローカル開発、および学習に使用するにはシンプルでハックが可能です。
5960
60-
Nevertheless, for realistically complex production use cases, it may be wiser to stand on the shoulders of some giant like [NGINX](https://www.nginx.com/) or [Apache](https://httpd.apache.org/) and that is exactly what we are going to do next: we are about to leverage NGINX to serve our vue.js app because it is considered to be one of the most performant and battle-tested solutions out there.
61+
それでも、現実的に複雑な本番環境のユースケースでは、 [NGINX](https://www.nginx.com/) [Apache](https://httpd.apache.org/) などの巨人の肩に乗るのが賢明でしょうし、それがまさに我々が次にやろうとしていることです。我々は最も性能が良く実戦で試されている解決策の1つだと考えられているという理由で、まさに NGINX を活用して vue.js アプリケーションを配信しようとしています。
6162

62-
Let's refactor our `Dockerfile` to use NGINX:
63+
`Dockerfile` NGINX を使うようにリファクタリングしましょう:
6364

6465
```docker
65-
# build stage
66+
# ビルド環境
6667
FROM node:9.11.1-alpine as build-stage
6768
WORKDIR /app
6869
COPY package*.json ./
6970
RUN npm install
7071
COPY . .
7172
RUN npm run build
7273
73-
# production stage
74+
# 本番環境
7475
FROM nginx:1.13.12-alpine as production-stage
7576
COPY --from=build-stage /app/dist /usr/share/nginx/html
7677
EXPOSE 80
7778
CMD ["nginx", "-g", "daemon off;"]
7879
```
7980

80-
Ok, let's see what's going on here:
81-
* we have split our original `Dockerfile` in multiple stages by leveraging the Docker [multi-stage builds](https://docs.docker.com/develop/develop-images/multistage-build/) feature;
82-
* the first stage is responsible for building a production-ready artifact of our Vue.js app;
83-
* the second stage is responsible for serving such artifact using NGINX.
81+
OK、ここで何が起きているか見てみましょう:
82+
* 元の `Dockerfile` Docker [マルチステージビルド](https://docs.docker.com/develop/develop-images/multistage-build/) 機能を活用して、複数のステージに分離しました。
83+
* はじめのステージでは Vue.js アプリケーションの本番環境に準備された成果物をビルドする責務があります。
84+
* 2つ目のステージではその成果物を NGINX を使って配信する責務があります。
8485

85-
Now let's build the Docker image of our Vue.js app:
86+
さて Vue.js アプリケーションを Docker イメージを使ってビルドしましょう:
8687

8788
```bash
8889
docker build -t vuejs-cookbook/dockerize-vuejs-app .
8990
```
9091

91-
Finally, let's run our Vue.js app in a Docker container:
92+
最後に、 Vue.js アプリケーション を Docker コンテナの中で実行しましょう:
9293

9394
```bash
9495
docker run -it -p 8080:80 --rm --name dockerize-vuejs-app-1 vuejs-cookbook/dockerize-vuejs-app
9596
```
9697

97-
We should be able to access our Vue.js app on `localhost:8080`.
98+
`localhost:8080` で Vue.js アプリケーションにアクセスができるでしょう。
9899

99-
## Additional Context
100+
<!-- ## Additional Context -->
101+
## さらなる背景
100102

101-
If you are reading this cookbook, chances are you already know why you decided to dockerize your Vue.js app. But if you simply landed on this page after hitting the Google's `I'm feeling lucky` button, let me share with you a couple of good reasons for doing that.
103+
もしあなたがこのクックブックを読んでいるなら、おそらく Vue.js アプリケーションを Docker 化することにした理由を既にわかっているでしょう。しかし、あなたが単に Google`I'm feeling lucky` ボタンを押した後にこのページにたどり着いたとしたら、いくつかのもっともな理由を共有しましょう。
102104

103-
Today's modern trend is to build applications using the [Cloud-Native](https://pivotal.io/cloud-native) approach which revolves mainly around the following buzzwords:
104-
* Microservices
105+
今日のモダンな流行りは、主に下記のバズワードを中心にしたアプローチとして [Cloud-Native](https://pivotal.io/cloud-native) を使ってアプリケーションを構築することです。
106+
* マイクロサービス
105107
* DevOps
106-
* Continuous Delivery
108+
* 継続的デリバリ
107109

108-
Let's see how these concepts actually affect our decision of dockerizing our Vue.js app.
110+
これらのコンセプトが実際にどうやって Vue.js アプリケーションを Docker 化するという決断に影響するか見ていきましょう。
109111

110-
### Effects of Microservices
112+
### マイクロサービスへの効果
111113

112-
By adopting the [microservices architectural style](https://martinfowler.com/microservices/), we end up building a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms. These services are built around business capabilities and independently deployable by fully automated deployment machinery.
114+
[マイクロサービスアーキテクチャスタイル](https://martinfowler.com/microservices/) を採用することによって、独自のプロセスで動き、軽量な機構で連携する小さなサービスの集まりとして単一のアプリケーションを構築することになります。これらのサービスはビジネスの機能を中心に構築され、完全に自動化されたデプロイ機構によって独立してデプロイ可能です。
113115

114-
So, committing to this architectural approach most of the time implies developing and delivering our front-end as an independent service.
116+
そのため、このアーキテクチャのアプローチへほとんどの時間を費やすことは、フロントエンドを独立したサービスとして開発・配信することを意味します。
115117

116-
### Effects of DevOps
118+
### DevOps への効果
117119

118-
The adoption of [DevOps](https://martinfowler.com/bliki/DevOpsCulture.html) culture, tools and agile engineering practices has, among other things, the nice effect of increasing the collaboration between the roles of development and operations. One of the main problem of the past (but also today in some realities) is that the dev team tended to be uninterested in the operation and maintenance of a system once it was handed over to the ops team, while the latter tended to be not really aware of the system's business goals and, therefore, reluctant in satisfying the operational needs of the system (also referred to as "whims of developers").
120+
[DevOps](https://martinfowler.com/bliki/DevOpsCulture.html) 文化、ツールおよびアジャイル開発の実践を採用することは、とりわけ開発と運用の役割の協力を増やす良い影響があります。過去の(しかし一部では実際に今でも)主な問題の1つは開発チームは一度運用チームに引き渡されたシステムの運用や保守には無関心な傾向にあり、後者はシステムのビジネスの目標を知らず、したがってシステムの運用上のニーズを満たすことを渋る(「開発者の気まぐれ」と言われる)傾向にあります。
119121

120-
So, delivering our Vue.js app as a Docker image helps reducing, if not removing entirely, the difference between running the service on a deveveloper's laptop, the production environment or any environment we may think of.
122+
そのため、 Vue.js アプリケーションを Docker イメージとして配信することは、全てを無くすことはないとしても、開発者のラップトップや本番環境など考えうる全ての環境で実行されるサービスの差を減らす助けになります。
121123

122-
### Effects of Continuous Delivery
124+
### 継続的デリバリへの効果
123125

124-
By leveraging the [Continuous Delivery](https://martinfowler.com/bliki/ContinuousDelivery.html) discipline we build our software in a way that it can potentially be released to production at any time. Such engineering practice is enabled by means of what is normally called [continuous delivery pipeline](https://martinfowler.com/bliki/DeploymentPipeline.html). The purpose of a continuous delivery pipeline is to split our build into stages (e.g. compilation, unit tests, integration tests, performance tests, etc.) and let each stage verify our build artifact whenever our software changes. Ultimately, each stage increases our confidence in the production readiness of our build artifact and, therefore, reduces the risk of breaking things in production (or any other environment for that matters).
126+
[継続的デリバリ](https://martinfowler.com/bliki/ContinuousDelivery.html) の規律を活用することで、いつでも本番にリリースされる可能性のあるやり方でソフトウェアを構築します。このようなエンジニアリングの実践は通常、 [継続的デリバリパイプライン](https://martinfowler.com/bliki/DeploymentPipeline.html) と呼ばれるものによって可能になります。継続的デリバリパイプラインの目的はビルドを段階(例:コンパイル、単体テスト、結合テスト、性能テストなど)に分け、ソフトウェアの変更のたびにそれぞれの段階でビルド成果物を検証することです。最終的に、それぞれの段階はプロダクションビルドの成果物の準備状況の自信を高め、したがって本番環境(またはそのような他の環境)で壊れるリスクを減らします。
125127

126-
So, creating a Docker image for our Vue.js app is a good choice here because that would represent our final build artifact, the same artifact that would be verified against our continuous delivery pipeline and that could potentially be released to production with confidence.
128+
そのため、 Vue.js アプリケーションから Docker イメージを作ることは最終的なビルド成果物、つまり継続的デリバリパイプラインで検証され、自信を持って本番環境に配信できる成果物を表すため、ここでは良い選択です。
127129

128-
## Alternative Patterns
130+
## 代替パターン
129131

130-
If your company is not into Docker and Kubernetes just yet or you simply want to get your MVP out the door, maybe dockerizing your Vue.js app is not what you need.
132+
もしあなたの会社が Docker Kubernetes を使っていない場合や、ただシンプルに MVP を世にリリースしたいという場合は、 Vue.js アプリケーションを Docker 化するのは求めているものではないかもしれません。
131133

132-
Common alternatives are:
133-
* leveraging an all-in-one platform like [Netlify](https://www.netlify.com/);
134-
* hosting your SPA on [Amazon S3](https://aws.amazon.com/s3/) and serving it with [Amazon CloudFront](https://aws.amazon.com/cloudfront/) (see [this](https://serverless-stack.com/chapters/deploy-the-frontend.html) link for a detailed guide).
134+
よくある代替パターンは以下の通りです:
135+
* [Netlify](https://www.netlify.com/) のような全部入りのプラットフォームを活用する。
136+
* SPA [Amazon S3](https://aws.amazon.com/jp/s3/) でホスティングし、 [Amazon CloudFront](https://aws.amazon.com/jp/cloudfront/)[こちら](https://serverless-stack.com/chapters/deploy-the-frontend.html) のリンクで詳細なガイドを読んでください)で配信する。

0 commit comments

Comments
 (0)
0