Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joelvoss/gcf-image-lit
Automatically optimize images stored in Cloud Storage that are requested through this Cloud Function.
https://github.com/joelvoss/gcf-image-lit
cloud-storage gcp google-cloud google-cloud-platform serverless
Last synced: about 1 hour ago
JSON representation
Automatically optimize images stored in Cloud Storage that are requested through this Cloud Function.
- Host: GitHub
- URL: https://github.com/joelvoss/gcf-image-lit
- Owner: joelvoss
- License: mit
- Created: 2021-03-13T18:44:13.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-02T10:19:25.000Z (8 months ago)
- Last Synced: 2024-11-11T21:12:01.901Z (about 2 months ago)
- Topics: cloud-storage, gcp, google-cloud, google-cloud-platform, serverless
- Language: JavaScript
- Homepage:
- Size: 4.39 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gcf-image-lit
Automatically optimize images stored in Cloud Storage that are requested
through this Cloud Function.For optimal performance, put the Cloud Function behind a CDN for an extra
layer of caching on top of the basic `max-age` caching.## Requirements
- Node v16+
- gcloud SDK## Development
(1) Install dependencies
```bash
$ npm i
# or
$ yarn
```(2) Run initial validation
```bash
$ ./Taskfile.sh validate
```(3) Test your function locally using the
[`@google-cloud/functions-framework`][functions-framework].```bash
$ ./Taskfile.sh dev
```> See [`./Taskfile.sh`](./Taskfile.sh) for more tasks to help you develop.
## Environment variables
| Variable Name | Required | Description |
| ------------- | -------- | ------------------------------------------------------------------------- |
| SRC_DIR | ✅ | Cloud Storage source directory from where the original images are fetched |
| DIST_DIR | ✅ | Cloud Storage destination directory where the optimized images are stored |
| FILE_DIR | | Directory prefix for files written to Cloud Storage |## Deployment
(1) Authenticate with GCP
```bash
$ gcloud auth login
```(2) Build and deploy
```bash
$ ./Taskfile.sh build$ gcloud functions deploy ${BUILD_NAME} \
--region=${BUILD_REGION} \
--project=${BUILD_PROJECT} \
--trigger-http \
--runtime=nodejs12 \
--entry-point=handler \
--memory=${BUILD_MEMORY} \
--max-instances=${BUILD_INSTANCES} \
--set-env-vars SRC_DIR=${SRC_DIR},DIST_DIR=${DIST_DIR},FILE_DIR=${FILE_DIR}
```> See [the official documentation][gcloud-deploy] for all available options.
---
_This project was set up by @jvdx/core_
[functions-framework]: https://github.com/GoogleCloudPlatform/functions-framework-nodejs
[gcloud-deploy]: https://cloud.google.com/sdk/gcloud/reference/functions/deploy