{"id":19432533,"url":"https://github.com/threemammals/george","last_synced_at":"2025-04-14T17:42:55.806Z","repository":{"id":66341551,"uuid":"200273533","full_name":"ThreeMammals/george","owner":"ThreeMammals","description":"The platform that runs the ThreeMammals website.","archived":false,"fork":false,"pushed_at":"2019-10-10T07:03:13.000Z","size":10394,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T17:42:30.285Z","etag":null,"topics":["docker-compose","headless-wordpress","headless-wp","rabbitmq","react-static","reactjs"],"latest_commit_sha":null,"homepage":"https://www.threemammals.com/","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThreeMammals.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-08-02T17:29:14.000Z","updated_at":"2024-11-28T15:49:10.000Z","dependencies_parsed_at":"2023-07-11T06:16:44.420Z","dependency_job_id":null,"html_url":"https://github.com/ThreeMammals/george","commit_stats":null,"previous_names":[],"tags_count":305,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeMammals%2Fgeorge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeMammals%2Fgeorge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeMammals%2Fgeorge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThreeMammals%2Fgeorge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThreeMammals","download_url":"https://codeload.github.com/ThreeMammals/george/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248929925,"owners_count":21184916,"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":["docker-compose","headless-wordpress","headless-wp","rabbitmq","react-static","reactjs"],"created_at":"2024-11-10T14:36:15.957Z","updated_at":"2025-04-14T17:42:55.764Z","avatar_url":"https://github.com/ThreeMammals.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# George\n\nThe platform that runs [https://www.threemammals.com/](https://www.threemammals.com/).\n\nGeorge uses Wordpress as a CMS. It pushes messages out of Wordpress when changes happen using the [Pushy](https://github.com/ThreeMammals/pushy) plugin. The messages are placed on a RabbitMQ topic and ingested via a NodeJs process into a Postgres database. When the messages are ingested the Wordpress post_content is parsed into a React tree before saving. There is a GraphQL API over the Postgres database. When the ingest process finishes another message is published to RabbitMQ saying the work is done. Another NodeJS process listens to this message and statically generates the website. Finally NGINX is running over the top of Wordpress, the GraphQL API and the website itself.\n\n## Why\n\nWhy not??? For reals though...my place of work has a headless Wordpress / React solution that calls the Wordpress \"REST\" APIs. We struggle with this because the APIs are not very performant and this has lead to some very complex caching and cache invalidation rules / processes. We have often talked about pushing the data out of Wordpress and storing it in a read optimised way (Please note maybe Postgres isnt this, its just to experiment). This would enable us in theory to look up everything on an index and get rid of our complex caching.\n\nI set out to build the barebones of this platform for the [https://threemammals.com](https://threemammals.com) website to see what is and isn't possible!!!\n\n## Features\n\nGeorge supports creating, editing and deleting posts. It is very basic. The posts will appear on a /blog path.\n\nThe website itself is statically generated using [https://github.com/react-static/react-static](https://github.com/react-static/react-static) but any react renderer would do.\n\nWhen the render process runs it uses GraphQL to load the React tree of a given post from the API. It then swaps out name strings for React component functions in memory. It throws the resulting tree to React render and away we go.\n\nOne of the cool things about react-static is that it supports incremental builds unlike Gatsby so we only build the article that has changed. Rather than the whole site! Unless we want to of course :)\n\n## Prerequisite\n\n- Node 10\n- Docker\n- Mac (only tested mac, definitely won't work on Windows, probably works on various Linux distributions)\n\n## Steps to build containers and george running locally\n\n1. Clone this repository\n2. Before you do anything create a self signed certificate for localhost and put it in `package/serve/certs/live/localhost`. If you don't know how to do this Google should help.\n3. `npm run bootstrap`\n4. `npm run lerna -- --scope=@george/wordpress install-pushy --stream` to install Pushy into Wordpress plugins.\n5. Make changes, git add and commit\n6. We can publish containers to either ECR or ACR by default. You can switch which repo you are using by editing `./packages/scripts/publish.sh` to point at `./packages/scripts/publish-azure.sh` or `./packages/scripts/publish-azure.sh`.\n7. Depending on your chosen container registry set the following environmental variables.\n    - Azure\n\n    ```bash\n    export GEORGE_ACR_LOGIN_NAME=XXX\n    export GEORGE_ACR_URL=XXX.azurecr.io\n    export GEORGE_ACR_USERNAME=XXX\n    export GEORGE_ACR_PASSWORD=XXX\n    ```\n\n    - AWS\n\n    ```bash\n    export GEORGE_ECR_URL=032803037394.dkr.ecr.eu-west-1.amazonaws.com\n    export GEORGE_AWS_REGION=eu-west-1\n    ```\n\n8. We publish npm packages scoped @george to a private repository using .npmrc via a process where we write an environmental variable called `GEORGE_NPMRC` into .npmrc and then delete it afterwards. This means in order to publish you need to set\n\n    ```bash\n    export GEORGE_NPMRC=\"registry=https://registry.npmjs.org/\\r\\n@george:XXXXXXXXX\"\n    ```\n\n    Where XXXXXXXXX is your details for the private repository. The value needs to be escaped.\n\n9. `npm run build`\n10. Run locally via docker compose `npm run start-dev`\n11. Setup wordpress:\n    1. Go to https://localhost/admin/wp-admin/install.php\n    2. Install WP \u0026 Login\n    3. Go to Plugins and Activate Pushy\n    4. Go to Settings \u003e Pushy Options and tick AMQPPublisher and enter rabbit as the location click Save Changes.\n    5. Go to Settings \u003e Permalinks and tick plain then save Changes.\n12. Check database migrations have worked\n    1. Go to http://localhost:8080 and login using the postgres details from docker-compose.yml\n    2. Check there is a table called posts in the database george.\n13. Check GraphQL is working\n    1. Go to https://localhost/api and verify GraphQL UI loads\n    2. Make a request to https://localhost/api with the content below\n\n    ```graphql\n    {\n      posts {\n        title\n      }\n    }\n\n    ```\n\n14. Check the website is working\n    1. Go to https://localhost/ and you should see the ThreeMammals homepage.\n    2. Click on Blog in the menu there should be no posts in the list.\n    3. Go to Wordpress and edit a post, click Update / Publish.\n    4. Go to https://localhost/blog/ and refresh the page for 30 seconds and the post should appear.\n        - If it doesn't check the logs for the render container. There is probably something wrong. Work out what it is or raise a GitHub issue.\n        - If it appears you are all good George is working.\n\n## Running database migrations locally\n\n1. Set the following environmental variables\n\n    ```bash\n    export GEORGE_POSTGRES_USER=example\n    export GOERGE_POSTGRES_PASSWORD=george\n    export GOERGE_POSTGRES_HOST=localhost\n    ```\n\n2. `lerna run --scope=@george/data migrate-up --stream` to migrate up.\n3. `lerna run --scope=@george/data migrate-down --stream` to migrate down.\n\n## Environmental variables\n\nSet these locally if you are doing any kind of debugging etc outside of docker-compose.\n\n```bash\nexport FQDN_OR_IP=localhost\nexport GEORGE_PUBLIC_API_URL=http://localhost:4000/\nexport INTERNAL_SITE_ROOL=https://localhost/\nexport WORDPRESS_SITE_ROOT=https://localhost/\nexport GEORGE_SITE_ROOT=https://localhost/\nexport GEORGE_RABBITMQ_URL=amqp://localhost\nexport GEORGE_DATABASE_HOST=localhost\nexport GEORGE_API_URL=http://localhost:4000/\n```\n\n## Deploying to a real environment\n\nI have a separate repository with a production docker-compose.yml and NGINX config.\n\nI mount the config on the serve container like so..\n\n```yml\n        volumes:\n        - /home/azureuser/default.conf:/etc/nginx/conf.d/default.conf\n```\n\nThese files contain all my [https://www.threemammals.com/](https://www.threemammals.com/) specific stuff. For example the production docker-compose.yml has lots of different values from environmental variables!\n\nAfter that it is up to you to work out how to deploy if you want to use it :) I suggest the easiest way would be docker-machine to a VM :P\n\nOne final hint I use [https://github.com/mjstealey/wordpress-nginx-docker](https://github.com/mjstealey/wordpress-nginx-docker) to get SSL into the serve container.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreemammals%2Fgeorge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreemammals%2Fgeorge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreemammals%2Fgeorge/lists"}