Skip to content

Template for the app using FastAPI/MySQL, that Includes user model & auth functionality.

License

Notifications You must be signed in to change notification settings

troyblakelydc/fastapi-mysql-docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastapi-mysql-docker

  • FastAPI
  • MySQL
  • Docker

Setup

Please install Docker and Docker compose first.

https://www.docker.com/

After installation, run the following command to create a local Docker container.

docker-compose build
docker-compose up -d

If you want to check the log while Docker container is running, then try to use following command:

docker-compose up

If Docker is running successfully, the API and DB server will be launched as shown in the following:

Be careful, it won't work if the port is occupied by another application.

If you want to check docker is actually working, then you can check it with following command:

docker ps

If you want to go inside of docker container, then try to use following command:

docker-compose exec mysql bash
docker-compose exec api bash

For shutdown of the docker instance, please use following command:

docker-compose down

Need a front-end app?

If you need a front-end app for this server-side & DB server.

You can clone the front-end template from:

Note

Python library packages

Some of the Python packages used in this app are defined in api/requirements.txt. Also you can add other packages there.

Environment variable

Some of environment variable, like a database name and user is defined in docker-compose.yml. You can customize it as you like.

If you will use docker, then please define your environment variable to docker-compose.yml. However, you will NOT use docker, then please create .env file for your API server.

DB Migrations

When creating DB docker container, docker will create predefined tables in mysql/db folder. That help your team to control versions of database.

The sample table definition has already been created with the name create_user_table.sql.

API documentation

http://localhost:8000/redoc

About

Template for the app using FastAPI/MySQL, that Includes user model & auth functionality.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.8%
  • Dockerfile 2.2%