{"id":13622074,"url":"https://github.com/cloudflare/postgres-postgrest-cloudflared-example","last_synced_at":"2025-04-12T19:53:03.304Z","repository":{"id":43304487,"uuid":"376907884","full_name":"cloudflare/postgres-postgrest-cloudflared-example","owner":"cloudflare","description":"Create a PostgreSQL database with a REST API, exposed to the internet securely with Cloudflare Tunnel","archived":false,"fork":false,"pushed_at":"2024-09-27T17:09:44.000Z","size":8,"stargazers_count":63,"open_issues_count":2,"forks_count":13,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T14:58:15.848Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/cloudflare.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-06-14T17:40:47.000Z","updated_at":"2025-01-09T23:08:17.000Z","dependencies_parsed_at":"2025-01-16T06:20:37.397Z","dependency_job_id":null,"html_url":"https://github.com/cloudflare/postgres-postgrest-cloudflared-example","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"bd90729d9f9c4987cc4574076cc5ffa4288886c0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fpostgres-postgrest-cloudflared-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fpostgres-postgrest-cloudflared-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fpostgres-postgrest-cloudflared-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fpostgres-postgrest-cloudflared-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudflare","download_url":"https://codeload.github.com/cloudflare/postgres-postgrest-cloudflared-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625509,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-01T21:01:13.603Z","updated_at":"2025-04-12T19:53:03.286Z","avatar_url":"https://github.com/cloudflare.png","language":null,"readme":"# Postgrest Docker example\n\nAn example `docker-compose` setup for configuring a PostgreSQL database and the associated PostgREST endpoint, which is exposed to the internet using `cloudflared`.\n\n## Initialize the containers\n\nYou can start up all the services in this project by running `docker-compose up`:\n\n```sh\n$ docker-compose up -d\n```\n\n_Note: depending on how your Docker installation is set up, you may need to preface the above command (and any other `docker-compose` examples) with `sudo`._\n\n## Example data\n\nYou can generate some example data by running the `create-example-data.sql` script inside of your running docker container:\n\n```sh\n$ docker-compose exec postgres psql -U user -d db -f /scripts/create-example-data.sql \n```\n\nThis will create a `users` table and a single user with the name `Kristian`.\n\n## Making requests\n\nA `cloudflared` tunnel will be generated when you run `docker-compose` up, such as `https://honolulu-devices-update-drink.trycloudflare.com`. You can find the currently active tunnel URL by looking through the `docker-compose` logs:\n\n```sh\n$ docker-compose logs cloudflared | grep trycloudflare\ncloudflared_1 | INFO[2021-06-14T17:26:05Z] | https://honolulu-devices-update-drink.trycloudflare.com\n```\n\nThis tunnel allows access to the PostgREST endpoint. You can make a few example requests to see data correctly returned from PostgreSQL to PostgREST, and then to your terminal:\n\n```sh\n$ curl https://honolulu-devices-update-drink.trycloudflare.com/users\n[{\"id\":1,\"name\":\"Kristian\"}]\n\n$ curl https://honolulu-devices-update-drink.trycloudflare.com/users?id=eq.1\n[{\"id\":1,\"name\":\"Kristian\"}]\n\n$ curl https://honolulu-devices-update-drink.trycloudflare.com/users?id=eq.2\n[]\n```\n\nYou can also create records using the PostgREST API, though you should go through the [PostgREST tutorial on user authentication](https://postgrest.org/en/stable/tut1.html) to secure your API:\n\n```sh\n$ curl https://honolulu-devices-update-drink.trycloudflare.com/users \\\n  -X POST \\\n  -H \"Content-type: application/json\" \\\n  -d '{\"name\": \"Dog\"}'\n\n$ curl https://honolulu-devices-update-drink.trycloudflare.com/users?name=eq.Dog\n[{\"id\":2, \"name\":\"Dog\"}]\n```\n\n## Tunnel configuration\n\nIf you'd like to create a permanent `cloudflared` tunnel at a custom endpoint, you can [configure your tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/configuration/config). The provided `cloudflared` directory will be exposed to the Docker container, so you can add `config.yml` and any relevant JSON/certificate files to authenticate and configure your tunnel.\n\n## Thanks\n\nThis repository and the (soon-to-come) tutorial for integrating with this on Cloudflare Workers was inspired by @eidam's great tutorial and sample codebase for running an authenticated and secure PostgreSQL, PostgREST, and `cloudflared` integration on Google Cloud, [available here](https://github.com/cloudflare/argo-tunnel-examples/tree/master/terraform-zerotrust-postgrest-worker).","funding_links":[],"categories":["Others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudflare%2Fpostgres-postgrest-cloudflared-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudflare%2Fpostgres-postgrest-cloudflared-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudflare%2Fpostgres-postgrest-cloudflared-example/lists"}