docker.md 2.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
Use of `Docker`
==============

## 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

14
Both images for the `backend` and the `frontend` are 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` and during development.
15

16
## Updating the images on Gitlab
17

18
### The hard / standard way
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

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
```

38
39
40
41
42
43
:warning: images should be versioned with meaningful tags.

### The automated way

You can find on [this repo](https://gitlab.utc.fr/rex-dri/ansible/tree/master/build-docker) an `ansible` script that automate the building/pushing of the images from a remote server. Very useful if you have a bad internet connection.

44
45
## Updating the images from Gitlab

46
To do so, run `make docker-pull`. (this should be automatic on image tag version change)
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61


## 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
```

## 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`.