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

dockerize-db #9

Closed
benjpalmer opened this issue Dec 26, 2019 · 1 comment
Closed

dockerize-db #9

benjpalmer opened this issue Dec 26, 2019 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@benjpalmer
Copy link
Collaborator

Containerize the development instance of MYSQL.

This will simplify setting up and running the application database locally. By adding a simple docker compose file, we can pull the database image from docker and when setting up a development environment. This will help do a few things:

  • Ensure all devs are using the same version of MYSQL
  • Lay the foundation for adding config/settings files to the Flask application because we have explicitly defined what the development database looks like.

This feature will have no breaking changes and should have bare minimum impact on the existing infrastructure. The only thing that will need to be updated is the README.

For the time being this is only aimed at being implemented in a development environment, this will not change the UI/front-end.

@zachtheclimber Docker is awesome although a bit intimidating if you are new to it. But here is an example of how simple this makes things. So assuming you have docker installed on your machine here is how this would work:

This is a simple docker-compse.yaml file example which would get added to the root project directory of MPV:

version: '3.3'
services:
  db:
    image: mysql:5.7
    restart: always
    environment:
      # Use root/password as user/password credentials
      MYSQL_DATABASE: 'mpv_db'
      MYSQL_ROOT_PASSWORD: 'password'
    ports:
      # <Port exposed> : < MySQL Port running inside container>
      - '3306:3306'
    expose:
      # Opens port 3306 on the container
      - '3306'
      # Where our data will be persisted
    volumes:
      - mpv_db:/var/lib/mysql
# Names our volume
volumes:
  mpv_db:
  1. Navigate to the root directory for MPV
  2. Run the shell command docker-compose up
    This will download and build a docker image of a MYSQL database using the specified version and environment variables specified in the docker-compose.yaml file.
  3. If you want to connect from the shell to the running database image run the command mysql -u root -p mpv_db -h 127.0.0.1 -P 3306
    Notice the port number 3306, inside of docker-compose.yaml we expose this port on the docker container and that will allow us to connect to the containerized instance of MYSQL via that port.

Let me know what you think! Here are a few links to some good reading about docker:

https://hub.docker.com/_/mysql/
https://severalnines.com/blog/mysql-docker-building-container-image

@benjpalmer benjpalmer added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 26, 2019
@benjpalmer benjpalmer self-assigned this Dec 26, 2019
@benjpalmer benjpalmer mentioned this issue Dec 27, 2019
@ghost
Copy link

ghost commented Dec 30, 2019

Sorry for the delay. Currently on vacation.

Super cool! I know a tiny bit about Docker, so I'm excited to learn more through implementing it with MPV. I also appreciate you leaving the option for a non-container setup as well. Thanks for the addition!

@ghost ghost closed this as completed Dec 30, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant