{"id":19701935,"url":"https://github.com/joelvoss/gcf-image-lit","last_synced_at":"2026-06-17T14:32:24.019Z","repository":{"id":37174686,"uuid":"347451593","full_name":"joelvoss/gcf-image-lit","owner":"joelvoss","description":"Automatically optimize images stored in Cloud Storage that are requested through this Cloud Function.","archived":false,"fork":false,"pushed_at":"2024-05-02T10:19:25.000Z","size":4603,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-29T01:26:50.366Z","etag":null,"topics":["cloud-storage","gcp","google-cloud","google-cloud-platform","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joelvoss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-13T18:44:13.000Z","updated_at":"2022-11-15T20:17:02.000Z","dependencies_parsed_at":"2023-02-08T06:46:18.843Z","dependency_job_id":"8d7bc763-3384-4569-af82-7b7f5a4cfe96","html_url":"https://github.com/joelvoss/gcf-image-lit","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/joelvoss/gcf-image-lit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelvoss%2Fgcf-image-lit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelvoss%2Fgcf-image-lit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelvoss%2Fgcf-image-lit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelvoss%2Fgcf-image-lit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelvoss","download_url":"https://codeload.github.com/joelvoss/gcf-image-lit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelvoss%2Fgcf-image-lit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34453431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-storage","gcp","google-cloud","google-cloud-platform","serverless"],"created_at":"2024-11-11T21:12:07.200Z","updated_at":"2026-06-17T14:32:24.014Z","avatar_url":"https://github.com/joelvoss.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gcf-image-lit\n\nAutomatically optimize images stored in Cloud Storage that are requested\nthrough this Cloud Run service.\n\nFor optimal performance, put the Cloud Run service behind a CDN for an extra\nlayer of caching on top of the basic `max-age` caching.\n\n## Requirements\n\n- Node v24+\n- gcloud SDK\n\n## Development\n\n(1) Install dependencies\n\n```bash\n$ npm i\n```\n\n(2) Run initial validation\n\n```bash\n$ ./Taskfile.sh validate\n```\n\nAvailable taskfile commands:\n\n```bash\n$ ./Taskfile.sh help\n```\n\nThe taskfile provides these tasks:\n\n- `./Taskfile.sh start` starts the built service\n- `./Taskfile.sh dev` runs the local dev harness and service in watch mode\n- `./Taskfile.sh build` builds the project into `dist/`\n- `./Taskfile.sh format` formats source and test files with `oxfmt`\n- `./Taskfile.sh lint` lints source and test files with `oxlint`\n- `./Taskfile.sh typecheck` runs `tsc --noEmit`\n- `./Taskfile.sh test` runs the Vitest suite\n- `./Taskfile.sh test --watch` or `./Taskfile.sh test -w` runs Vitest in watch mode\n- `./Taskfile.sh validate` runs typecheck, lint, and tests\n- `./Taskfile.sh clean` removes build artifacts and dependencies\n- `./Taskfile.sh deploy` builds and deploys the current package version to Cloud Run\n- `./Taskfile.sh docker-build` builds the version-tagged Docker image locally\n\n## Local Dev Harness\n\nRun the local development harness:\n\n```bash\n$ ./Taskfile.sh dev\n```\n\nThen open `http://127.0.0.1:8787` in a browser.\n\nThis runs two local processes:\n\n- the real service on `http://127.0.0.1:8080`\n- a Vite harness on `http://127.0.0.1:8787`\n\nThe harness serves the demo page, exposes files from `tests/fixtures`, proxies\n`/optimize` to the service, and writes optimized output into `./.dev-harness-cache/`.\n\nThe service runs with `node --watch`, so server restarts happen automatically\nafter rebuilds.\n\nThe `dev` task uses local defaults from `set_build_env dev`:\n\n- `STORAGE_BACKEND=local`\n- `SRC_DIR=./tests`\n- `DIST_DIR=./.dev-harness-cache`\n\n## Local Service\n\nRun the Cloud Run service locally from the built artifact:\n\n```bash\n$ ./Taskfile.sh build\n$ ./Taskfile.sh start\n```\n\nThe service listens on `http://127.0.0.1:8080` by default and respects `PORT`.\n\n## Environment variables\n\n| Variable Name | Required | Description                                                               |\n| ------------- | -------- | ------------------------------------------------------------------------- |\n| SRC_DIR       | ✅       | Cloud Storage source directory from where the original images are fetched |\n| DIST_DIR      | ✅       | Cloud Storage destination directory where the optimized images are stored |\n| FILE_DIR      |          | Directory prefix for files written to Cloud Storage                       |\n\n## Deployment\n\nThe deploy and Docker build tasks derive `BUILD_NAME` and `BUILD_VERSION` from\n`package.json`. By default, the image URI is derived as:\n\n```text\n${BUILD_REGION}-docker.pkg.dev/${BUILD_PROJECT}/${BUILD_REPOSITORY}/${BUILD_NAME}:${BUILD_VERSION}\n```\n\nThe taskfile uses `set_build_env \u003cbuild-env\u003e` to resolve shared configuration\nfor different contexts. The current built-in contexts are `deploy` and `dev`.\n\nDeploy-oriented defaults come from `set_build_env deploy`:\n\n- `BUILD_REGION=europe-west3`\n- `BUILD_PROJECT=replace-me`\n- `BUILD_REPOSITORY=docker`\n- `BUILD_MEMORY=512MB`\n- `BUILD_INSTANCES=10`\n\n(1) Authenticate with GCP\n\n```bash\n$ gcloud auth login\n```\n\n(2) Build a container image and deploy\n\n```bash\n$ ./Taskfile.sh deploy\n```\n\nOverride deploy-time values by exporting environment variables before running\nthe task:\n\n```bash\n$ BUILD_PROJECT=\u003cgcp-project\u003e BUILD_MEMORY=\u003cmemory\u003e BUILD_INSTANCES=\u003ccount\u003e ./Taskfile.sh deploy\n```\n\nTo build the image locally with Docker instead:\n\n```bash\n$ ./Taskfile.sh docker-build\n```\n\nOr manually:\n\n```bash\n$ gcloud builds submit --tag ${BUILD_IMAGE}\n\n$ gcloud run deploy ${BUILD_NAME} \\\n    --region=${BUILD_REGION} \\\n    --project=${BUILD_PROJECT} \\\n    --image=${BUILD_IMAGE} \\\n    --port=8080 \\\n    --memory=${BUILD_MEMORY} \\\n    --max-instances=${BUILD_INSTANCES} \\\n    --allow-unauthenticated \\\n    --set-env-vars SRC_DIR=${SRC_DIR},DIST_DIR=${DIST_DIR},FILE_DIR=${FILE_DIR}\n```\n\n\u003e See [the official documentation][gcloud-deploy] for all available options.\n\n[gcloud-deploy]: https://cloud.google.com/sdk/gcloud/reference/run/deploy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelvoss%2Fgcf-image-lit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelvoss%2Fgcf-image-lit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelvoss%2Fgcf-image-lit/lists"}