课程: Supabase Essential Training
Running Supabase in Docker
- [Instructor] Getting Supabase set up in a local Docker container is fast and mostly automatic. Let's do it now. Before setting up a local copy of Supabase, you need to have a Docker server running. The Docker website will attempt to select the right platform based on the browser you are using. Once you have confirmed that download Docker. Once you have downloaded Docker, you'll need to install it. I have already installed Docker on my computer and have it running. If you would like to learn more about installing and running Docker, I recommend checking out this course in the LinkedIn Learning Library. Once Docker is installed and running, it is time to start up Supabase. If Supabase isn't already initialized, run supabase-init. I'm going to go to my project folder here, so cd into kitchen-supply-company, and so if I type in supabase-init, it is going to error out here because I already have a project and that is okay. If you ever need to overwrite the initialized project, you can use the force flag, but I do not need to do that, so I am going to leave this alone. If you don't already have a project here, this is going to create this Supabase folder with a configuration file and a lightweight structure for more Supabase resources. I'm now going to type in supabase start, and this is going to start the installation process for our local Supabase instance. From here, Supabase will download the necessary Docker images for you, start the server, and then output a set of credentials. And now the installation is done. Notice there's a service roll key and an anonymous key. Just like in the hosted version of Supabase. These can be used in the code base for your locally running application. They are a separate set of credentials from the hosted version, so be sure not to mix them up. There's also a PostgreSQL connection string you can use to connect to the locally running database, which you can use with a PostgreSQL client if you wish. Also, notice there's a Studio URL here. If you follow that URL, it will take you to a locally hosted Supabase dashboard. I'm just going to copy this and load this up in my web browser, and here we are. From here, you can use most of the same features as you would on the hosted version of Supabase. There are a few features that are hosted only, but most of the core ones you'll use frequently are here. So for instance, you can go to the table editor and you can add a new table just like you can in the hosted version. You can also go to the SQL editor notice the assistant is here, but if you try to prompt in the AI chat, it will error out. So I'm going to try to prompt here, create a table for tracking recipes. After entering that prompt, it just disappeared and it didn't really show me a message or anything. That is because the AI chat is only available in the hosted instance of Supabase. Besides that, I can look through tables, I can look at database settings, and I can also look at the authentication panel. Once Docker is installed and running, it only takes a couple of commands in the terminal to get Supabase running as well. Remember, you get a separate set of credentials to use for developing locally.
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。