Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add example on how to extend Docker Container #455

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM node:18-alpine

WORKDIR /app
ENV HOME=/home
COPY package-lock.json package.json index.js ./
RUN npm ci --omit=dev
RUN npm install --global
RUN npm install --location=global

WORKDIR /workdir
ENTRYPOINT [ "cspell-cli" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ npm install -g git+https://github.com/streetsidesoftware/cspell-cli
docker run -v $PWD:/workdir ghcr.io/streetsidesoftware/cspell:latest "**"
```

See [Extending the Docker Container to include German](https://github.com/streetsidesoftware/cspell-cli/tree/main/docker/german/README.md)

## Usage

`cspell --help`:
Expand Down
8 changes: 8 additions & 0 deletions docker/german/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ghcr.io/streetsidesoftware/cspell:8.4.1

WORKDIR /app
ENV HOME=/home
RUN npm install @cspell/dict-de-de@3.2.0
RUN cspell-cli link add @cspell/dict-de-de

WORKDIR /workdir
79 changes: 79 additions & 0 deletions docker/german/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Extending the Docker Container to include German

The CSpell container has all the default dictionaries installed, but to include other dictionaries,
it is necessary to extend the container.

**`Dockerfile`**

```dockerfile
FROM ghcr.io/streetsidesoftware/cspell:8.4.1

WORKDIR /app
# Setting HOME is necessary to set the location of CSpell's global config.
ENV HOME=/home
# Install the dictionaries we want
RUN npm install @cspell/dict-de-de@3.2.0
# Link the dictionaries so that CSpell is aware of them by default.
RUN cspell-cli link add @cspell/dict-de-de

# Restore the working directory to the virtual directory.
WORKDIR /workdir
```

## Building

```sh
docker build -t cspell-german:latest .
```

## Running

Example of `cspell trace` command:

```sh
docker run -v $PWD:/workdir \
cspell-german:latest \
trace Strasse \
--locale=de --dictionary-path=short
```

**Result:**

```
Word F Dictionary Dictionary Location
Strasse - [flagWords]* From Settings `flagWords`
Strasse - [ignoreWords]* From Settings `ignoreWords`
Strasse - [suggestWords]* From Settings `suggestWords`
Strasse - [words]* From Settings `words`
Strasse - aws* [node_modules]/aws.txt
Strasse - companies* [node_modules]/companies.txt
Strasse - computing-acronyms* [node_modules]/computing-acronyms.txt
Strasse - cryptocurrencies* [node_modules]/cryptocurrencies.txt
Straße * de-de* [node_modules]/de_DE.trie.gz
Strasse - filetypes* [node_modules]/filetypes.txt.gz
Strasse - public-licenses* [node_modules]/public-licenses.txt.gz
Strasse - softwareTerms* [node_modules]/softwareTerms.txt
Strasse - web-services* [node_modules]/webServices.txt
```

## CSpell Configuration

It is necessary to enable the locale for the dictionary to be used. On the command line, it is `--locale=<lang>`, i.e. `--locale=de,en` for German and English.

In a CSpell Configuration file:

**`cspell.config.yaml`**

```yaml
language: de,en
```

**`cspell.json`**

```json
{
"language": "de,en"
}
```

<!--- cspell:ignore Strasse Straße --->
3 changes: 3 additions & 0 deletions docker/german/cspell.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: en,de
words:
- workdir
Loading