Skip to content

Commit

Permalink
TASK: Add codeblocks to code examples
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
Simon authored and thaJeztah committed Mar 4, 2021
1 parent 615433a commit 5e78271
Show file tree
Hide file tree
Showing 13 changed files with 787 additions and 609 deletions.
73 changes: 40 additions & 33 deletions compose/completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ available.

2. Place the completion script in `/etc/bash_completion.d/`.

```shell
sudo curl -L https://raw.githubusercontent.com/docker/compose/{{site.compose_version}}/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
```
```console
$ sudo curl \
-L https://raw.githubusercontent.com/docker/compose/{{site.compose_version}}/contrib/completion/bash/docker-compose \
-o /etc/bash_completion.d/docker-compose
```

#### Mac

Expand All @@ -31,19 +33,21 @@ available.
1. Install with `brew install bash-completion`.
2. After the installation, Brew displays the installation path. Make sure to place the completion script in the path.

For example, when running this command on Mac 10.13.2, place the completion script in `/usr/local/etc/bash_completion.d/`.
For example, place the completion script in `/usr/local/etc/bash_completion.d/`.

```shell
sudo curl -L https://raw.githubusercontent.com/docker/compose/{{site.compose_version}}/contrib/completion/bash/docker-compose -o /usr/local/etc/bash_completion.d/docker-compose
```
```console
$ sudo curl \
-L https://raw.githubusercontent.com/docker/compose/{{site.compose_version}}/contrib/completion/bash/docker-compose \
-o /usr/local/etc/bash_completion.d/docker-compose
```

3. Add the following to your `~/.bash_profile`:

```shell
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
```
```shell
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
```

4. You can source your `~/.bash_profile` or launch a new terminal to utilize
completion.
Expand All @@ -54,11 +58,11 @@ completion.

2. Add the following lines to `~/.bash_profile`:

```shell
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
. /opt/local/etc/profile.d/bash_completion.sh
fi
```
```shell
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
. /opt/local/etc/profile.d/bash_completion.sh
fi
```

3. You can source your `~/.bash_profile` or launch a new terminal to utilize
completion.
Expand All @@ -69,39 +73,42 @@ Make sure you have [installed `oh-my-zsh`](https://ohmyz.sh/) on your computer.

#### With oh-my-zsh shell

Add `docker` and `docker-compose` to the plugins list in `~/.zshrc` to run autocompletion within the oh-my-zsh shell. In the following example, `...` represent other Zsh plugins you may have installed.
Add `docker` and `docker-compose` to the plugins list in `~/.zshrc` to run
autocompletion within the oh-my-zsh shell. In the following example, `...`
represent other Zsh plugins you may have installed.

```shell
plugins=(... docker docker-compose
)
plugins=(... docker docker-compose)
```

#### Without oh-my-zsh shell

1. Place the completion script in your `/path/to/zsh/completion` (typically `~/.zsh/completion/`):

```shell
$ mkdir -p ~/.zsh/completion
$ curl -L https://raw.githubusercontent.com/docker/compose/{{site.compose_version}}/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose
```
```console
$ mkdir -p ~/.zsh/completion
$ curl \
-L https://raw.githubusercontent.com/docker/compose/{{site.compose_version}}/contrib/completion/zsh/_docker-compose \
-o ~/.zsh/completion/_docker-compose
```

2. Include the directory in your `$fpath` by adding in `~/.zshrc`:

```shell
fpath=(~/.zsh/completion $fpath)
```
```shell
fpath=(~/.zsh/completion $fpath)
```

3. Make sure `compinit` is loaded or do it by adding in `~/.zshrc`:

```shell
autoload -Uz compinit && compinit -i
```
```shell
autoload -Uz compinit && compinit -i
```

4. Then reload your shell:

```shell
exec $SHELL -l
```
```console
$ exec $SHELL -l
```

## Available completions

Expand Down
35 changes: 19 additions & 16 deletions compose/django.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,22 @@ In this step, you create a Django starter project by building the image from the

1. Change to the root of your project directory.

2. Create the Django project by running
the [docker-compose run](reference/run.md) command as follows.
2. Create the Django project by running the [docker-compose run](reference/run.md)
command as follows.

```console
$ sudo docker-compose run web django-admin startproject composeexample .
```

This instructs Compose to run `django-admin startproject composeexample`
in a container, using the `web` service's image and configuration. Because
the `web` image doesn't exist yet, Compose builds it from the current
directory, as specified by the `build: .` line in `docker-compose.yml`.
This instructs Compose to run `django-admin startproject composeexample`
in a container, using the `web` service's image and configuration. Because
the `web` image doesn't exist yet, Compose builds it from the current
directory, as specified by the `build: .` line in `docker-compose.yml`.

Once the `web` service image is built, Compose runs it and executes the
`django-admin startproject` command in the container. This command
instructs Django to create a set of files and directories representing a
Django project.
Once the `web` service image is built, Compose runs it and executes the
`django-admin startproject` command in the container. This command
instructs Django to create a set of files and directories representing a
Django project.

3. After the `docker-compose` command completes, list the contents of your project.

Expand Down Expand Up @@ -198,7 +198,7 @@ In this section, you set up the database connection for Django.
db_1 | The default database encoding has accordingly been set to "UTF8".
db_1 | The default text search configuration will be set to "english".
. . .
<...>
web_1 | July 30, 2020 - 18:35:38
web_1 | Django version 3.0.8, using settings 'composeexample.settings'
Expand All @@ -219,7 +219,9 @@ In this section, you set up the database connection for Django.
> inside `settings.py` and add your Docker host name or IP address to the list.
> For demo purposes, you can set the value to:
>
> ALLOWED_HOSTS = ['*']
> ```python
> ALLOWED_HOSTS = ['*']
> ```
>
> This value is **not** safe for production usage. Refer to the
> [Django documentation](https://docs.djangoproject.com/en/1.11/ref/settings/#allowed-hosts) for more information.
Expand All @@ -238,19 +240,20 @@ In this section, you set up the database connection for Django.

6. Shut down services and clean up by using either of these methods:

* Stop the application by typing `Ctrl-C`
in the same shell in where you started it:
* Stop the application by typing `Ctrl-C` in the same shell in where you
started it:

```console
Gracefully stopping... (press Ctrl+C again to force)
Killing test_web_1 ... done
Killing test_db_1 ... done
```

* Or, for a more elegant shutdown, switch to a different shell, and run [docker-compose down](reference/down.md) from the top level of your Django sample project directory.
* Or, for a more elegant shutdown, switch to a different shell, and run
[docker-compose down](reference/down.md) from the top level of your
Django sample project directory.

```console
vmb at mymachine in ~/sandbox/django
$ docker-compose down
Stopping django_web_1 ... done
Expand Down
Loading

0 comments on commit 5e78271

Please sign in to comment.