Skip to content

Commit e8144b6

Browse files
authored
build: stop using docker for build/watch workflow (angular#741)
1 parent 487cfc5 commit e8144b6

23 files changed

+673
-181
lines changed

.dockerignore

-3
This file was deleted.

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text=auto
2+
*.patch -text

.github/dependabot.yml

-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,3 @@ updates:
1313
directory: "/" # Location of package manifests
1414
schedule:
1515
interval: "daily"
16-
- package-ecosystem: "docker" # See documentation for possible values
17-
directory: "/tools/dockerbuild" # Location of package manifests
18-
schedule:
19-
interval: "daily"
20-

.github/workflows/build-and-test.yml

+47-28
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,52 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
build:
12+
test:
1313
runs-on: ubuntu-latest
14-
1514
steps:
16-
- uses: actions/checkout@v3
17-
with:
18-
submodules: true
19-
20-
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
21-
- name: Get yarn cache directory path
22-
id: yarn-cache-dir-path
23-
run: echo "::set-output name=dir::$(yarn cache dir)"
24-
- uses: actions/cache@v3
25-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
26-
with:
27-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
28-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
29-
restore-keys: |
30-
${{ runner.os }}-yarn-
31-
32-
- name: Use Node.js
33-
uses: actions/setup-node@v3
34-
with:
35-
node-version-file: .node-version
36-
- name: Install
37-
run: yarn install
38-
- name: Test
39-
run: yarn test
40-
- name: Build
41-
run: yarn build
15+
- uses: actions/checkout@v3
16+
with:
17+
submodules: true
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version-file: .node-version
21+
cache: yarn
22+
- run: yarn install
23+
- run: yarn test
24+
build-ubuntu:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
with:
29+
submodules: true
30+
- uses: actions/setup-node@v3
31+
with:
32+
node-version-file: .node-version
33+
cache: yarn
34+
- run: yarn install
35+
- run: yarn build
36+
build-windows:
37+
runs-on: windows-latest
38+
steps:
39+
- uses: actions/checkout@v3
40+
with:
41+
submodules: true
42+
- uses: actions/setup-node@v3
43+
with:
44+
node-version-file: .node-version
45+
cache: yarn
46+
- run: yarn install
47+
- run: yarn build
48+
shell: pwsh
49+
build-macos:
50+
runs-on: macos-latest
51+
steps:
52+
- uses: actions/checkout@v3
53+
with:
54+
submodules: true
55+
- uses: actions/setup-node@v3
56+
with:
57+
node-version-file: .node-version
58+
cache: yarn
59+
- run: yarn install
60+
- run: yarn build

.github/workflows/deploy-preview.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/setup-node@v3
2525
with:
2626
node-version-file: .node-version
27+
cache: yarn
2728
- name: Install
2829
run: yarn install
2930
- name: Build

.github/workflows/deploy-production.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
uses: actions/setup-node@v3
2323
with:
2424
node-version-file: .node-version
25+
cache: yarn
2526
- name: Install
2627
run: yarn install
2728
- name: Build

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.tmp
2-
build-out
2+
build
33
node_modules

CONTRIBUTING.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,14 @@ $ git submodule update --init
6363
```
6464
#### 開発用サーバーを使った作業
6565

66-
開発用サーバーを起動すると、ビルド結果を確認しながら翻訳作業ができます。
67-
開発用サーバーの起動中は、`aio-ja/content`内のファイルが変更されたときに自動的に再ビルドされます。
66+
開発用ローカルサーバーを起動すると、ビルド結果を確認しながら翻訳作業ができます。
6867

6968
```
7069
$ yarn start
7170
```
7271

73-
**注意**
74-
75-
- 事前に[Docker](https://www.docker.com/get-started)の実行環境を用意してください。
76-
- 初回はDockerイメージのビルド時間が長いので、コーヒーを淹れながら待ちます。
77-
- Dockerイメージサイズが10GB程度と非常に大きいため、ホストマシンのストレージ残量に注意してください。
72+
- ローカルサーバーの準備ができると自動的にブラウザが起動します
73+
- `aio-ja` ディレクトリ内のファイルを変更すると自動的に再ビルドされます
7874

7975
#### ビルド
8076

@@ -84,13 +80,11 @@ $ yarn start
8480
$ yarn build
8581
```
8682

87-
ビルドが完了すると、 `build-out` ディレクトリにビルド結果が出力されます。
83+
ビルドが完了すると、 `build/aio/dist` ディレクトリにビルド結果が出力されます。
8884
好みのツールで開発サーバーを立ててビルドされたサイトを確認できます。
8985

9086
**注意**
9187

92-
- 事前に[Docker](https://www.docker.com/get-started)の実行環境を用意してください。
93-
- ビルド時間がとても長いので、コーヒーを淹れながら待ちます。
9488
- MacOSにおいて、ビルド処理の途中でOSのファイルディスクリプタを使い切ってしまうことがあります。
9589
その場合は次のように最大数を増やす必要があります。
9690

docker-compose.yml

-23
This file was deleted.

firebase.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hosting": {
3-
"public": "build-out",
3+
"public": "build/aio/dist",
44
"ignore": [
55
"firebase.json",
66
"**/.*",

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
"license": "MIT",
88
"private": true,
99
"scripts": {
10-
"prebuild": "rm -rf build-out && mkdir build-out",
11-
"build": "docker-compose run --rm build-aio",
12-
"build:docker": "docker-compose build --parallel",
10+
"build": "zx tools/build.mjs",
1311
"lint": "yarn ~~textlint",
1412
"lint:fix": "yarn ~~textlint --fix",
15-
"start": "docker-compose up --remove-orphans watch-aio",
13+
"start": "zx tools/watch.mjs",
1614
"test": "npm run lint && yarn test:patch",
1715
"test:patch": "git apply -v --check --directory origin ./scripts/git-patch/*.patch",
1816
"update-origin": "./update-origin.sh",
1917
"~~textlint": "textlint 'aio-ja/**/!(*.en).md'"
2018
},
2119
"devDependencies": {
20+
"chokidar": "3.5.3",
2221
"glob": "^8.0.3",
2322
"prh-rules": "prh/rules",
2423
"textlint": "^12.2.1",
2524
"textlint-filter-rule-comments": "^1.2.2",
26-
"textlint-rule-prh": "^5.3.0"
25+
"textlint-rule-prh": "^5.3.0",
26+
"zx": "7.0.8"
2727
}
2828
}

tools/build.mjs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env zx
2+
3+
import { chalk } from 'zx';
4+
import { applyPatches, buildAIO, copyRobots, copyLocalizedFiles, modifySitemap, resetBuildDir } from './lib/common.mjs';
5+
6+
try {
7+
console.log(chalk.green('==== setup ===='));
8+
await setup();
9+
console.log(chalk.green('==== preBuild ===='));
10+
await preBuild();
11+
console.log(chalk.green('==== build ===='));
12+
await build();
13+
console.log(chalk.green('==== postBuild ===='));
14+
await postBuild();
15+
} catch (e) {
16+
console.error(chalk.red(e));
17+
process.exit(1);
18+
}
19+
20+
async function setup() {
21+
await resetBuildDir();
22+
}
23+
24+
async function preBuild() {
25+
// copy translated files
26+
console.log(chalk.cyan('Copy localized files...'));
27+
await copyLocalizedFiles();
28+
29+
// apply patches
30+
console.log(chalk.cyan('Apply patches...'));
31+
await applyPatches();
32+
}
33+
34+
async function build() {
35+
await buildAIO();
36+
}
37+
38+
async function postBuild() {
39+
await copyRobots();
40+
await modifySitemap();
41+
}

tools/dockerbuild/build.dockerfile

-20
This file was deleted.

tools/dockerbuild/package.json

-8
This file was deleted.

tools/dockerbuild/scripts/apply-localization.mjs

-7
This file was deleted.

tools/dockerbuild/scripts/build-aio.mjs

-7
This file was deleted.

tools/dockerbuild/scripts/setup-aio.mjs

-4
This file was deleted.

tools/dockerbuild/scripts/watch-aio.mjs

-26
This file was deleted.

tools/dockerbuild/watch.dockerfile

-29
This file was deleted.

0 commit comments

Comments
 (0)