docker.md 1.94 KB
Newer Older
1
Use of Docker
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
==============

## General comment

As said in the introduction, this project makes use of `docker` and `docker-compose`. Their are several `Dockerfile` spraid across the project that creates the required `docker` image.

Then the `docker-compose.yml` file coordinates everything: environment variables, ports, volumes, etc.

You can have a look at those files for more comments.

## Use in Gitlab

The `backend` image is also stored on [https://gitlab.utc.fr/rex-dri/rex-dri/container_registry](https://gitlab.utc.fr/rex-dri/rex-dri/container_registry) to be easily used in `Gitlab CI`.

As it seemed not possible to do the same for the `frontend` image due to the fact that the `node_modules` folder couldn't be kept during `CI`, the image is basically regenerated in `CI`.
When ran locally, the `npm i` command (installing the `Node` dependencies) is run everytime with `make up` to make sure your `node_modules` folder is up to date.

## Updating the image on Gitlab

If you are not connected to the registry yet, do it:

```bash
docker login registry.gitlab.utc.fr
```

To update the images stored on the Gitlab repository, run for instance:

```bash
docker build ./backend --compress --tag registry.gitlab.utc.fr/rex-dri/rex-dri/backend:latest
```

And push it:

```bash
docker push registry.gitlab.utc.fr/rex-dri/rex-dri/backend:latest
```

## Updating the images from Gitlab

To do so, run `make docker-pull`.


## Issues with `__pycache__`

If you have issues at some point with `__pycache__` files, you can delete them:

```bash
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | sudo xargs rm -rf
```
51 52 53 54 55 56

## Issues with Django migrations

With the docker setup, Django migrations are created from within the container and as a result those files are own by the docker user.

If you have issues with git regarding the migrations files (i.e. they don't disappear when you change branch), you need to become an owner of the files: `chown -R $(id -u):$(id -g) backend`.