Skip to content

Commit

Permalink
feat(slim-lti-skeleton): publishable to GAE
Browse files Browse the repository at this point in the history
Add Google App Engine configuration files, including Node deployment script
  • Loading branch information
battis committed Feb 8, 2025
2 parents 88cbb9a + 0979599 commit 39dfc15
Show file tree
Hide file tree
Showing 9 changed files with 1,224 additions and 1 deletion.
1,145 changes: 1,145 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packages:
- 'packages/*'
- 'templates/*'
10 changes: 10 additions & 0 deletions templates/slim-lti-skeleton/.gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*
.DS_Store
.htaccess
!/.env
!/app.yaml
!/php.ini
!/composer.*
!/app
!/public
!/src
3 changes: 3 additions & 0 deletions templates/slim-lti-skeleton/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.env
.env.*
.idea/
.vscode/
/coverage/
/node_modules/
/vendor/
/logs/*
!/logs/README.md
Expand Down
5 changes: 5 additions & 0 deletions templates/slim-lti-skeleton/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
runtime: php83
basic_scaling:
max_instances: 1
app_engine_apis: true
entrypoint: serve public/index.php
41 changes: 41 additions & 0 deletions templates/slim-lti-skeleton/bin/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import gcloud from '@battis/partly-gcloudy';
import cli from '@battis/qui-cli';
import path from 'node:path';

(async () => {
const {
values: { force }
} = await gcloud.init({
env: {
root: path.dirname(import.meta.dirname)
},
args: {
flags: {
force: {
short: 'f',
default: false
}
}
}
});

if (process.env.PROJECT && !force) {
await gcloud.batch.appEngineDeployAndCleanup({ retainVersions: 2 });
} else {
const { project } = await gcloud.batch.appEnginePublish();

await gcloud.services.enable(gcloud.services.API.CloudFirestoreAPI);
const [{ name: database }] = JSON.parse(
cli.shell.exec(
`gcloud firestore databases list --project=${project.projectId} --format=json --quiet`
)
);
cli.shell.exec(
`gcloud firestore databases update --type=firestore-native --database="${database}" --project=${project.projectId} --format=json --quiet`
);

await gcloud.services.enable(
gcloud.services.API.CloudMemorystoreforMemcachedAPI
);
}
})();
4 changes: 3 additions & 1 deletion templates/slim-lti-skeleton/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
}
},
"scripts": {
"post-create-project-cmd": "pnpm install || npm install",
"start": "php -S localhost:8080 -t public",
"test": "phpunit"
"test": "phpunit",
"deploy": "node ./bin/deploy.js"
}
}
12 changes: 12 additions & 0 deletions templates/slim-lti-skeleton/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"description": "Provide Node-based deployment wizard to Google App Engine",
"type": "module",
"scripts": {
"deploy": "node ./bin/deploy.js"
},
"devDependencies": {
"@battis/partly-gcloudy": "^0.6.3",
"@battis/qui-cli": "^0.9.1"
},
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
}
4 changes: 4 additions & 0 deletions templates/slim-lti-skeleton/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://cloud.google.com/php/grpc
extension=grpc.so
extension=memcached.so
extension=protobuf.so

0 comments on commit 39dfc15

Please sign in to comment.