This repository contains sources of server part of Wroclive iOS app.
(Psst… the app itself is also open-sourced!)
We use Google Cloud for hosting.
We extensively use their free tier, to keep our hosting costs low. The only thing that we actually pay for is storage for App Engine instances, but this is about 0.20 zł (~$0.05) per month (only the instances in US are free and we chose Frankfurt because of GDPR and latency).
Anyway, this is how it works:
And this is the push notification pipeline:
Firestore
make deploy
), then remember to put GCP-Credentials.json
for app-engine-firestore
service account in AppEngine directoryComputeEngine-Updater
ComputeEngine-Updater
ComputeEngine-Notifications
AppEngine
ComputeEngine-Notifications
backend
/home/USERNAME/on-vm-startup.sh
ComputeEngine
instance (installations, updates etc.)make package
to create .zip
package with all of the ComputeEngine
modulesmake upload
to send package to GCP
make connect
to log into GCP
./install-package.sh
exit
make restart
to restart VM (if needed)Firestore
GCP-Credentials.json
for compute-engine-firestore
service account in ComputeEngine-Updater directoryPub/Sub
subscriberbackend-update-gtfs-data
message runs ComputeEngine-Updater
Compute Engine
instance startsGCP-Credentials.json
for pubsub
service account in ComputeEngine-PubSub directoryFirestore
Compute Engine
instance startsGCP-Credentials.json
for compute-engine-firestore
service accountTwitter-Credentials.json
- see Twitter-Credentials-example.json
for detailsAPN-Key.p8
- key for Apple Push Notification serviceAPN-Credentials.json
- see APN-Credentials-example.json
for detailsbackendStart
function
backend
instance on Compute Engine
and starts itCloud Scheduler
backendStop
function
backend
instance on Compute Engine
and stops itCloud Scheduler
Pub/Sub - following topics need to be created:
backend-stop
backend-start
backend-update-gtfs-data
0 3 * * *
): publish backend-stop
message on Pub/Sub
15 3 * * *
): publish backend-start
message on Pub/Sub
30 3 * * *
): publish backend-update-gtfs-data
message on Pub/Sub
IAM & Admin - following service accounts are used:
App Engine default service account
App Engine
app-engine-firestore
- account used by App Engine
to read/write data in Firestore
compute-engine-firestore
- account used in ComputeEngine-Updater
and ComputeEngine-Notifications
to read/write data in Firestore
pubsub
- account used for creating subscriptions in ComputeEngine-PubSub
wroclive.app/api
(this will also keep our App Engine
instance alive)
We use winstonjs/winston with @google-cloud/logging-winston
backend
Add following filers:
resource.type="gae_app" AND (textPayload=~"(Starting app|Quitting on terminated signal)$" OR protoPayload.methodName="google.appengine.v1.Versions.CreateVersion")
protoPayload.userAgent =~ "Wroclive.*"
Error reporting - standard reporting by mail
Unix siege
tool + baseline - used to check burst performancepostman.json - configuration file to import into postman app (it contains our endpoints + some basic tests)
Wroclive is licensed under the Mozilla Public License 2.0 license. See LICENSE for more information.