https://github.com/fromzeroedu/flask-mysql-boilerplate 를 기초로 한다.
$ brew services list
$ brew services start mysql
$ mysql -uroot -p
mysql> CREATE DATABASE counter;
mysql> CREATE USER 'counter_user'@'%' IDENTIFIED BY 'counter_password';
mysql> ALTER USER 'counter_user'@'%' IDENTIFIED WITH mysql_native_password BY 'counter_password'; # for mysql 8.0
mysql> GRANT ALL PRIVILEGES ON counter.* TO 'counter_user'@'%';
mysql> FLUSH PRIVILEGES;
mysql> \q
$ git clone https://github.com/fromzeroedu/flask-mysql-boilerplate.git
$ cd flask-mysql-boilerplate
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip
$ pip install -r requirements.txt
$ pip install --upgrade Werkzeug
$ pip install cryptography # for mysql 8.0
$ flask db init
$ flask db migrate
$ flask db upgrade
$ flask run
- Serving Flask app "manage.py" (lazy loading)
- Environment: development
- Debug mode: on
- Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
- Restarting with stat
- Debugger is active!
- Debugger PIN: 148-251-086
$ git clone https://github.com/fromzeroedu/flask-mysql-boilerplate.git
- - /opt/flask-mysql-boilerplate:/counter_app
+ - .:/counter_app
-Werkzeug==0.15.3
+Werkzeug==1.0.1
$ docker-compose up -d
$ docker logs -f counterappmysql_db_1
[Note] mysqld: ready for connections.
위의 로그를 확인하고, Ctrl+C
$ docker exec -it counterappmysql_web_1 flask db init
$ docker exec -it counterappmysql_web_1 flask db migrate
$ docker exec -it counterappmysql_web_1 flask db upgrade