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

MDBF-558: Reorganize docker-compose and dockerfiles for feedback plugin #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

an3l
Copy link
Contributor

@an3l an3l commented Apr 13, 2023

  • Dockerfiles changes:

    • mariadb - do not use pip installation and related .py script, since new layers will be added in final image - delete .py script - create new bash script to initialize database, create new user and give proper grants - generate smaller image

    • app

      • do not install mariadb to increase generated image size
      • instead create networks in docker-compose file that will ensure proper inter container communication and set proper settings in app.settings.py - do not install gunicorn as dependency, but rather define it as an requirements to be installed with pip - do not create logs folder, but rather mount that folder during container creation.
    • nginx - remove Dockerfile and use vanilla nginx and mount needed configuration in docker-compose

  • docker-compose changes:

    • environment variables, use proper env vars for db service, add container names
    • add networks tag in docker-compose for proper inter container communication
    • mount volume for gunicorn in logs directory
    • use mariadb.conf.d configuration file container path instead conf
    • bump the docker compose version to minimum version for networks
    • add healty check for mariadb container
    • use long syntax for conditions on web service to wait on mariadb service to be healthy
    • remove db dependency for nginx
  • Test showing created user:

$ docker exec -it prod-mariadb mariadb -uroot -p1234 -e "select user,host from mysql.user"
+-------------+-----------+
| User        | Host      |
+-------------+-----------+
| feedback    | %         |
| root        | %         |
| feedback    | localhost |
| mariadb.sys | localhost |
| mysql       | localhost |
| root        | localhost |
+-------------+-----------+
  • Test showing grants for created user:
$ docker exec -it prod-mariadb mariadb -uroot -p1234 -e "show grants for feedback@localhost"
+-----------------------------------------------------------------------------------------------------------------+
| Grants for feedback@localhost                                                                                   |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `feedback`@`localhost` IDENTIFIED BY PASSWORD '*06794F85E875D3ADBFE47B4FA68F8186667F44A9' |
| GRANT ALL PRIVILEGES ON `feedback_plugin`.* TO `feedback`@`localhost`                                           |
| GRANT ALL PRIVILEGES ON `test_feedback_plugin`.* TO `feedback`@`localhost`                                      |
+-----------------------------------------------------------------------------------------------------------------+
  • Update Readme.md

- Dockerfiles changes:
  - `mariadb`
    - do not use pip installation and related `.py` script, since new
    layers will be added in final image
    - delete `.py` script
    - create new `bash` script to initialize database, create new user and give proper grants
    - generate smaller image

  - `app`
    - do not install mariadb to increase generated image size
    - instead create networks in docker-compose file that will ensure proper
      inter container communication and set proper settings in `app.settings.py`
    - do not install gunicorn as dependency, but rather define it as an
      requirements to be installed with pip
    - do not create `logs` folder, but rather mount that folder during container
      creation.

  - `nginx`
    - remove Dockerfile and use vanilla `nginx` and mount needed
      configuration in docker-compose

- `docker-compose` changes:
  - environment variables, use proper env vars for db service, add
    container names
  - add networks tag in `docker-compose` for proper inter container communication
  - mount volume for `gunicorn` in  `logs` directory
  - use `mariadb.conf.d` configuration file container path instead `conf`
  - bump the `docker compose` version to minimum version for `networks`
  - add healty check for `mariadb` container
  - use long syntax for conditions on `web` service to wait on `mariadb` service
    to be healthy
  - remove `db` dependency for `nginx`

- Test showing created user:
```bash
$ docker exec -it prod-mariadb mariadb -uroot -p1234 -e "select user,host from mysql.user"
+-------------+-----------+
| User        | Host      |
+-------------+-----------+
| feedback    | %         |
| root        | %         |
| feedback    | localhost |
| mariadb.sys | localhost |
| mysql       | localhost |
| root        | localhost |
+-------------+-----------+
```

- Test showing grants for created user:
```bash
$ docker exec -it prod-mariadb mariadb -uroot -p1234 -e "show grants for feedback@localhost"
+-----------------------------------------------------------------------------------------------------------------+
| Grants for feedback@localhost                                                                                   |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `feedback`@`localhost` IDENTIFIED BY PASSWORD '*06794F85E875D3ADBFE47B4FA68F8186667F44A9' |
| GRANT ALL PRIVILEGES ON `feedback_plugin`.* TO `feedback`@`localhost`                                           |
| GRANT ALL PRIVILEGES ON `test_feedback_plugin`.* TO `feedback`@`localhost`                                      |
+-----------------------------------------------------------------------------------------------------------------+

```
- Update `Readme.md`
@an3l
Copy link
Contributor Author

an3l commented Apr 13, 2023

@cvicentiu , @fauust please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant