I whipped the old body and tried a sample that uses Firebase for user authentication. I've followed the Google Application Engine sample, so it's a memo. https://cloud.google.com/appengine/docs/standard/python3/building-app?hl=ja
The environment is ubuntu 18.04 of WSL1 (Windows Subsystem Linux).
First, a memo of the method for executing the sample. After that, a memorandum at the time of execution.
Switch accounts properly.
$ gcloud config set account [email protected]
$ gcloud config configurations list
Prepare the project.
$ gcloud projects list
$ gcloud projects create [YOUR_PROJECT_ID] --set-as-default
$ gcloud app create --project=[YOUR_PROJECT_ID]
$ gcloud projects describe [YOUR_PROJECT_ID]
git clone.
https://github.com/GoogleCloudPlatform/python-docs-samples
Use python-docs-samples/appengine/standard_python3/building-an-app /
When running locally
$ python3 -m venv env
$ source env/bin/activate
(env)> pip install -r requirements.txt
After
$ python3 main.py
It works normally. Return from the virtual environment with ``` deactivate``.
Deploy.
$ gloucd app deploy
I made it because there is no .gcloudignore. If the files under ./env created at the time of the operation check earlier remain, all local files will be uploaded together at the time of deploy. So, as a quick and reliable way, I erased everything with `rm -rf ./env/``` and then
`gcloud app deploy```. ^^;)
$ gloud app browse
View in your browser. You can also see the log. If the service name is default (unless you have changed the settings in app.yaml)
$ gcloud app logs tail -s default
building-an-app-1
It worked normally. There was script.js in ./static/. I can understand flask and routing somehow. Do you put it in static? There is a setting in app.yaml to upload this.
building-an-app-2
pip install -r reqirements.txt gives an error ``` error: invalid command'bdist_wheel'` ``. So I dealt with it below, but I wonder if I skipped it after all.
pip install scrapy
pip3 install wheel
pip3 install tornado
The deployment was fine. I don't know how to use Datasotre on GCP.
building-an-app-3
It's finally time to use Firebase.
Prepare Firebase. I was told as follows, but I'm not sure. I'm worried about the price, but I'm surprised that if you turn off firebase, his GCP project will also disappear.
Things to keep in mind when adding Firebase to your Google Cloud project --Google Cloud and Firebase billing for your project will be shared --Details: Because billing is enabled for your project, the Firebase Blaze plan will be applied and your Firebase items will be included in your Cloud billing every cycle. --User roles and permissions in the project are shared --Details Deleting a Firebase project also deletes the Google Cloud project and deletes all resources contained in the project. This operation is irreversible. However, many Firebase services can be manually disabled.
For more information, do I have to log in and read it carefully? I followed the instructions for the time being. https://console.firebase.google.com/
(1) Creating a Firebase project
--Created a project (though it wouldn't be a repetitive task) --Added mail, password, and Gmail in SIGN-IN METHOD of Authentication. --Added the domain name that was previously tested with gcloud app browse in the authenticated domain. PROJECT_ID. REGION_ID.r.appspot.com PROJECT_ID
(2) Creating an app
In the overview, select Web under "Add app". When registering the app, you will be asked for a name, so if you put it in properly, a code to paste it was generated.
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "",
authDomain: "PROJECT_ID.firebaseapp.com",
projectId: "PROJECT_ID",
storageBucket: "PROJECT_ID.appspot.com",
messagingSenderId: "691267092448",
appId: "",
measurementId: ""
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
I was advised to paste it at the bottom of the
tag, so I did. However, when I actually run it and connect with a browser, I get angry to initialize Firebase.If the URL is registered
<!-- Initialize Firebase -->
<script src="/__/firebase/init.js"></script>
It seemed that it should be done, but it didn't work. After all, I pasted it into the header of templates/index.html and it worked.
In the operation check, I was able to register my e-mail address and password normally. I don't know where the registration data is. Is it somewhere in the Firebase project? .. ..
I learned later. If you read it carefully, it says various things, but for the time being
--Firebase rates. There is also a free tier instead of a pay-as-you-go system. There is a restriction that the project cannot be extended on Google Cloud Platform. You should consider whether you can use it in the free frame. --Check where the user data is. Is it Google Datastore? ――Assuming that you manage users with Firebase, I think it can be used from multiple apps. I have to study how to separate the user authentication part from the WEB page part. .. .. ――If you manage users with Firebase and put user data in Cloud Storage, what kind of configuration would you like? I also have to study DB. .. The destination is long, hey. ..
For the time being, I wrote a memo when I ran Google's tutorial. It was around this time that I wanted to make sure that I could use it properly and provide some services. (2021/01/03)
Recommended Posts