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

docs: fact-check docs/dev/how-to-develop-using-docker.md #9999

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 19 additions & 19 deletions docs/dev/how-to-develop-using-docker.md
Expand Up @@ -62,28 +62,28 @@ Run the following to open a bash shell within the `backend` container:
docker compose exec backend bash
```

You should see `root@<CONTAINER_ID>:/#` (opened root shell): you are now within the Docker container and can begin typing some commands !
You should see `root@<CONTAINER_ID>:/#` (opened root shell): you are now within the Docker container and can begin typing some commands!

### Checking permissions

Navigate to the directory the specific directory and run
Navigate to the specific directory and run

```
ls -lrt
```
It will list all the directories and their permission status.
It will list all directories and their permissions.

### Creating directory

Navigate to your specific directory using `cd` command and run
Navigate to your specific directory using `cd` and run

```
mkdir directory-name
```

### Running minion jobs

[Minion](https://docs.mojolicious.org/Minion) is a high-performance job queue for Perl. [Minion](https://docs.mojolicious.org/Minion) is used in [openfoodfacts-server](https://github.com/openfoodfacts/openfoodfacts-server) for time-consuming import and export tasks. These tasks are processed and queued using the minion jobs queue. Therefore, they are called minion jobs.
[Minion](https://docs.mojolicious.org/Minion) is a high-performance job queue for Perl, used in [openfoodfacts-server](https://github.com/openfoodfacts/openfoodfacts-server) for time-consuming import and export tasks. These tasks are processed and queued using the minion jobs queue. Therefore, they are called minion jobs.

Go to `/opt/product-opener/scripts` and run

Expand Down Expand Up @@ -113,28 +113,28 @@ Use `exit` to exit the container.
## Making code changes

In the dev environment, any code change to the local directory will be written
on the container. That said, some code changes require a restart of the `backend`
to the container. That said, some code changes require a restart of the `backend`
container, or rebuilding the NPM assets.


## Getting away from make up

`make up` is a good command for starters,
but it's not the right one to use if you develop on a daily bases, because it maybe slow,
but it's not the right one to use if you develop on a daily basis, because it may be slow,
as it does a full rebuild, which, in dev mode, should only be necessary in a few cases.

On a daily bases you could better run those:
On a daily basis you could better run those:

* `docker compose up` to start and monitor the stack.
* `docker compose restart backend` to account for a code change in a `.pm` file
(cgi `pl` files do not need a restart)
* `docker compose stop` to stop them all

If some important file changed (like Dockerfile or cpanfile, etc.), or in case of doubt,
If some important file changed (like Dockerfile or cpanfile, etc.), or if in doubt,
you can run `docker compose build` (or maybe it's a good time to use `make up` once)

You should explore the [docker compose commands](https://docs.docker.com/compose/reference/)
most are useful!
You should explore the [docker compose commands](https://docs.docker.com/compose/reference/).
Most are useful!


### Live reload
Expand Down Expand Up @@ -170,11 +170,11 @@ See the [`mongo` shell docs](https://www.mongodb.com/products/shell) for more co

## Adding environment variables

If you need some value to be configurable, it is best to set is as an environment variable.
If you need some value to be configurable, it is best to set it as an environment variable.

To add a new environment variable `TEST`:

* In `.env` file, add `TEST=test_val` [local].
* In a `.env` file, add `TEST=test_val` [local].
* In `.github/workflows/container-deploy.yml`, add `echo "TEST=${{ secrets.TEST }}" >> .env` to the "Set environment variables" build step [remote]. Also add the corresponding GitHub secret `TEST=test_val`.
* In `docker-compose.yml` file, add it under the `backend` > `environment` section.
* In `conf/apache.conf` file, add `PerlPassEnv TEST`.
Expand All @@ -191,22 +191,22 @@ there are different possible strategies.

### a set env script

docker compose takes it settings from, in order of priority:
docker compose takes its settings from, in decreasing priority:
* the environment
* the `.env` file

So one strategy to have a different instance,
can be to keep same `.env` file, but super-seed some env variables to tweak the configuration.
This is a good strategy for the pro plateform.
can be to keep the same `.env` file, but override some env variables to tweak the configuration.
This is a good strategy for the pro platform.

For this case we have a
[`setenv-pro.sh`](https://github.com/openfoodfacts/openfoodfacts-server/blob/main/setenv-pro.sh)
[`setenv.sh`](https://github.com/openfoodfacts/openfoodfacts-server/blob/main/env/setenv.sh)
script.

To use it, open a terminal, where you want to be in pro environment and simply use:

```bash
. setenv-pro.sh
. setenv.sh off-pro
```

then you can use whatever docker compose command.
Expand All @@ -217,7 +217,7 @@ See also [Developing on the producers platform](how-to-develop-producer-platform

### different .env file

This strategy might be the right one if your settings differs a lot.
This strategy might be the right one if your settings differ a lot.

You will need:

Expand Down