Skip to content

Commit 045d003

Browse files
Dev Container の追加 (#55)
Co-authored-by: 3w36zj6 <[email protected]>
1 parent 04dc4a6 commit 045d003

File tree

6 files changed

+74
-1
lines changed

6 files changed

+74
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Rust v1.77 as a base image
2+
FROM rust:1.77-slim
3+
4+
RUN apt-get update && \
5+
apt-get install -y --no-install-recommends \
6+
curl \
7+
# install python3, jinja2 pyyaml
8+
python3 \
9+
python3-pip \
10+
&& python3 -m pip install --break-system-packages jinja2 PyYAML \
11+
# install nodejs and serve
12+
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
13+
&& apt-get install -y nodejs \
14+
&& npm install -g [email protected] \
15+
&& apt-get clean \
16+
&& rm -rf /var/lib/apt/lists/* \
17+
18+
WORKDIR /workspace
19+
ENV PATH="/root/.cargo/bin:${PATH}"

.devcontainer/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ローカル環境を構築するDockerfile
2+
3+
[Docker](https://docs.docker.com/)を用いてWebページの仕上がりを確認できます。
4+
以下の操作はDockerがインストール済み、かつDockerデーモンを起動していることが前提となります。
5+
6+
7+
## VS Codeを使用している場合
8+
9+
[Dev Container](https://code.visualstudio.com/docs/devcontainers/containers)を使用します。
10+
Visual Studio Codeでtypst-jp.github.ioディレクトリを開き、以下の操作を実施してください。
11+
1. Ctrl+Shift+Pから`> Dev Containers: Reopen in Container`を実行
12+
2. Webサーバーが起動したらブラウザで http://localhost:3000 に接続
13+
3. ページを更新した際には、Ctrl+Shift+Pから`> Tasks: Run task`を実行し`gen: typst-jp documentation`を選択。ビルドが完了したらブラウザを更新。
14+
15+
16+
## 別のエディターを使用している場合
17+
18+
ターミナルからDockerfileをビルドして、コマンド実行します。
19+
typst-jp.github.io ディレクトリ上で以下のコマンドを実行してください。
20+
1. Docker imageをビルドしてコンテナを作成
21+
```
22+
docker build . -f .devcontainer/Dockerfile -t typst-jp-doc
23+
docker run --name typst-jp-doc -p 3000:3000 -it -v "$(pwd):/workspace" -w /workspace --rm typst-jp-doc /bin/bash
24+
```
25+
2. Dockerコンテナ内でページを生成
26+
```
27+
cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && npx serve -n ./dist
28+
```
29+
3. Webサーバーが起動したらブラウザで http://localhost:3000 に接続
30+
4. ファイルを更新した際には、2 のコマンドを一旦 Ctrl+C で終了して再度実行、その後ブラウザを更新。

.devcontainer/devcontainer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "typst-jp-domumentation",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".."
6+
},
7+
"forwardPorts": [3000],
8+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
9+
"workspaceFolder": "/workspace",
10+
"postStartCommand": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && npx serve -n ./dist"
11+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# General
2-
.vscode
2+
# .vscode
33
.idea
44
_things
55
desktop.ini

.vscode/tasks.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "gen: typst-jp documentation",
6+
"type": "shell",
7+
"command": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && echo reload or open http://localhost:3000",
8+
"problemMatcher": []
9+
}
10+
]
11+
}

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ python ./gen.py
5050

5151
Node.jsがインストールされている場合は、`npx serve ./dist`でプレビューできます。
5252

53+
上記のローカル環境を構築するDockerfileも整備しております。詳細は[.devcontainer/README.md](.devcontainer/README.md)をご参照ください。
54+
5355
## スタイルマニュアル
5456

5557
スタイルマニュアルでは、当プロジェクトにおける翻訳の品質確保のための、統一したスタイルの参照基準を提供します。具体的には、基本、文体、表記、用語の4つの観点から、翻訳の際に留意すべき事項を示します。

0 commit comments

Comments
 (0)