-
Notifications
You must be signed in to change notification settings - Fork 2
Setting up your instance
After obtaining a copy of mipa (best done by forking and cloning the repository if you wish to contribute), do the following to run your instance.
These instructions are current as of 2020.10.14. If you notice that something in the process has changed, please help update this documentation.
- Go to https://console.firebase.google.com/ (you may need to create an account first)
- Click Add project. Name the new project something like "mipa-your-name". Enabling Google Analytics is optional.
- Once the Firebase project is created, click on the </> icon to add a web app. Give the app a nickname, like "my mipa web app". Check the box to set up Firebase Hosting. Then click Register app.
- Ignore "Add Firebase SDK" instructions. Mipa's code already has this set up. So just click Next.
- Install firebase-tools per on-screen instructions.
- Per on-screen instructions, sign in to Google; but don't initiate your project with firebase init or deploy it yet. Just click continue to console.
- On the firebase console, click Authentication. Then Get started to set up sign-in methods; enable Email/Password.
- On the firebase console, click Cloud Firestore. Then Create database; select Start in production mode; pick a database location that makes sense for you (note down the location; we'll need it later), then enable.
- From the bottom of the left navigation panel, change the Spark plan to Blaze plan. (This is needed to make http requests from Cloud Functions, which we need for updating the currency exchange rates used within mipa.)
- Make a copy of the .env_sample file and name it .env.
- Back on the Firebase Console, go to Settings > General.
- In the newly created .env file, add in your Firebase project's credentials from the above steps. .env is already in .gitignore so the file will not be synced back to the repository.
- Make a copy of the .firebaserc_sample file and name it .firebaserc.
- In the file, in the "default" property, use your project id. .firebaserc is likewise already in .gitignore and will not be synced back to the repository.
cd functions
npm install
cd ..
We need this for updating currency exchange rates.
- Find the location that you noted down when you created the Firestore database. Check it against this locations list: https://cloud.google.com/functions/docs/locations. Your region code should look something like
us-central1
. You may also pick a region other than the region of your Firestore database, if you have good reason to do so. - Decide on a schedule to update the currency exchange rates. This is the string that may replace the
every 12 hours
in the callfunctions.pubsub.schedule('every 12 hours')
. For the syntax, see https://cloud.google.com/appengine/docs/standard/python/config/cronref#schedule_format. If you have no other special considerations,every 12 hours
is a reasonable choice. - If you need to specify the time zone, use a value from the TZ database name column from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- go to fixer.io and sign up for a free account to get an access key.
- Run the command below with the information you just prepared:
firebase functions:config:set update_exchange_rates.region="your-region-code" update_exchange_rates.schedule="daily" update_exchange_rates.time_zone="Etc/UTC" fixer_io.access_key="your-access-key"
For the rest of the project we use yarn instead of npm because of the more deterministic way it chooses dependencies. This helps us developers keep our dependencies identical.
If you don't have yarn installed yet, follow these instructions to install it: https://classic.yarnpkg.com/en/docs/install/
Then:
yarn install
This will deploy to the environment you configured in your .env file.
quasar build
firebase deploy
If all went well, mipa will be running at https://your-project-id.web.app. Register an account for yourself, and try things out!