- Copy the
.env.sample
to.env
and fill in the required values.
cp .env.sample .env
- Enable secret manager API
gcloud services enable secretmanager.googleapis.com
- Init
gcloud
and select the project or select a project using the following command:
gcloud init
gcloud config set project {project-id}
- Fill all the .env files with the required values then run the script
generate-secrets.sh
to generate the secrets.
./generate-secrets.sh
Put private key in secrets/apple.p8
(SubscriptionKey_63T65XFP9S.p8) and update apple
object in config.js
.
Put the chat id and bot token in the .env
file.
Set the allowed domains in the .env
file.
Usage of upload.single("file")
in app.post
:
const upload = multer({ dest: path.join(\_\_dirname, "uploads/") });
app.post(
"/event/:id/upload",
jwtDecodeMiddleware,
upload.single("file"),
uploadFile
);
npm install
npm run dev
Deploy repo to github then create a trigger in cloud build to deploy the app.
gcloud builds submit --config cloudbuild.yaml
Create a service in cloud run and deploy the image.
gcloud run deploy YOUR_SERVICE_NAME \
--image gcr.io/$PROJECT_ID/YOUR_SERVICE_NAME \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--cpu 1 \
--memory 128Mi \
--max-instances 1
- Allow accesss IP from everywhere to enable Cloud Run to connect to MongoDB.
brew install mkcert
brew install nss # if you use Firefox
mkcert -install
mkcert localhost # or your domain like TeoBook.fritz.box
then use https
:
https.createServer({
key: fs.readFileSync("TeoBook.fritz.box-key.pem"),
cert: fs.readFileSync("TeoBook.fritz.box.pem"),
}, app).listen(port, host, () => {