{"id":24645165,"url":"https://github.com/thepatrickniyo/docker-compose-demo","last_synced_at":"2026-04-11T06:02:17.103Z","repository":{"id":107052430,"uuid":"473314868","full_name":"thepatrickniyo/docker-compose-demo","owner":"thepatrickniyo","description":"A project that runs a Node server and a create-react-app app via two separate containers, using Docker Compose.","archived":false,"fork":false,"pushed_at":"2022-03-24T08:53:38.000Z","size":457,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-08T19:54:53.931Z","etag":null,"topics":["create-react-app","docker","docker-compose","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/thepatrickniyo.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":"2022-03-23T18:38:25.000Z","updated_at":"2022-03-24T04:15:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"b5e6efab-9da8-499d-ab07-865672cfc6a2","html_url":"https://github.com/thepatrickniyo/docker-compose-demo","commit_stats":null,"previous_names":["thepatrickniyo/docker-compose-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thepatrickniyo/docker-compose-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepatrickniyo%2Fdocker-compose-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepatrickniyo%2Fdocker-compose-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepatrickniyo%2Fdocker-compose-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepatrickniyo%2Fdocker-compose-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thepatrickniyo","download_url":"https://codeload.github.com/thepatrickniyo/docker-compose-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepatrickniyo%2Fdocker-compose-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31670383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"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":["create-react-app","docker","docker-compose","nodejs"],"created_at":"2025-01-25T14:14:23.120Z","updated_at":"2026-04-11T06:02:17.075Z","avatar_url":"https://github.com/thepatrickniyo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node + Create React App + Docker Compose\n\nA project that runs a Node server and a create-react-app app via two separate containers, using Docker Compose.\n\n## Development\n\n```\ndocker-compose up\n```\n\nFor development, the `server/` and `client/` directories have their own docker containers, which are configured via the `docker-compose.yml` file.\n\nThe client server is spun up at `localhost:3000` and it proxies internally to the server using the linked name as `server:8080`.\n\nThe local directories are mounted into the containers, so changes will reflect immediately. However, changes to package.json will likely need to a rebuild: `docker-compose down \u0026\u0026 docker-compose build \u0026\u0026 docker-compose up`.\n\n### Notes\n\n#### Adding new scss files\n\nIn a previous version of this, you needed to restart the client for new scss files to be recognized by the watch command. This may have changed (TODO: test if this still matters with react-scripts updates):\n\n```\ndocker-compose restart client\n```\n\n#### Installing npm dependencies\n\nAll changes to `node_modules` should happen _inside_ the containers. Install any new dependencies by inside the container. You can do this via `docker-compose run`, but it’s easier to just upadte a running container and avoid having to rebuild everything:\n\n```\ndocker-compose exec client\n```\n\nThen inside:\n\n```\nnpm install --save \u003cnew_dependency\u003e\n```\n\n## Production\n\n```\ndocker-compose -f docker-compose.prod.yml up\n```\n\nFor production, this uses the Dockerfile at the root of the repo. It creates a static build of the client React app and runs Express inside server, which handles both the API and serving of React files.\n\nAs a result, different code is executing to serve the React files, but all of the API calls should remain the same. The difference between development and production isn’t ideal, but it does offer the simplicity of having the entire app run in one server on one machine.\n\nThis is one of multiple ways a Node + React app could be setup, as suggested [here](https://daveceddia.com/create-react-app-express-production/):\n\n- **Keep them together** - have Express serve both the API and React files\n- **Split them apart** - have Express API on one machine and the React files on another (e.g., on S3 and use CORS to access the API)\n- **Put the API behind a proxy** - use something like NGINX to proxy the Express API server and React static files separately\n\nThis project uses the “keep them together” approach. For better performance, you can set up a proxy (like Cloudflare) in between your server and the Internet to cache the static files. Or with some extra work you can fashion it to do either of the other two options.\n\n## Notes\n\n### Using docker compose\n\nI have `comp` aliased to `docker-compose` on my computer.\n\nStart via:\n\n```\ncomp up\n\n# or detached\ncomp up -d\n```\n\nRun a container of the server image via:\n\n```\ncomp run server /bin/bash\n```\n\nCheck status:\n\n```\ncomp ps\n```\n\nStop:\n\n```\ncomp down\n```\n\nRun the production image:\n\n```\ncomp -f docker-compose.prod.yml up\n```\n\nNOTE: if any dependencies change in package.json files, you probably will need to rebuild the container for the changes to appear, e.g.,\n\n```\ncomp down\ncomp build\ncomp up\n```\n\n### Setup references\n\nReferences for setting up a Node project with Docker and docker-compose:\n\n- https://nodejs.org/en/docs/guides/nodejs-docker-webapp/\n- https://blog.codeship.com/using-docker-compose-for-nodejs-development/\n- http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html\n\nExpress + React:\n\n- https://daveceddia.com/create-react-app-express-production/\n- http://ericsowell.com/blog/2017/5/16/create-react-app-and-express\n- https://medium.freecodecamp.org/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0\n- https://medium.freecodecamp.org/how-to-host-a-website-on-s3-without-getting-lost-in-the-sea-e2b82aa6cd38\n\n### Author\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthepatrickniyo%2Fdocker-compose-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthepatrickniyo%2Fdocker-compose-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthepatrickniyo%2Fdocker-compose-demo/lists"}