From 5bf1bceeb7d49f37f9a34942f825afc8b81b3121 Mon Sep 17 00:00:00 2001 From: Keith Perfetti Date: Wed, 23 Jul 2025 17:15:53 -0400 Subject: [PATCH 1/7] Hardlinking in gitmodules as it does not take variables --- .gitmodules | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index ed938dd..eb020fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ [submodule "repo_refs/react1-app"] path = repo_refs/react1-app - url = ${FRONTEND_BUILD_CONTEXT} + url = https://github.com/perfetti/react1-app.git [submodule "repo_refs/react2-app"] path = repo_refs/react2-app - url = ${BACKEND_BUILD_CONTEXT} + url = https://github.com/perfetti/react2-app.git [submodule "repo_refs/rails-app"] path = repo_refs/rails-app - url = ${API_BUILD_CONTEXT} + url = https://github.com/perfetti/rails-app.git From 21749d6d0de03a7d1281cd7a5f37f7c2c8164458 Mon Sep 17 00:00:00 2001 From: Keith Perfetti Date: Wed, 23 Jul 2025 18:17:18 -0400 Subject: [PATCH 2/7] moving scripts into bin/ --- build_github.sh => bin/build_github.sh | 3 +++ build_local.sh => bin/build_local.sh | 2 +- setup_local.sh => bin/setup_local.sh | 0 bin/up_local.sh | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) rename build_github.sh => bin/build_github.sh (78%) rename build_local.sh => bin/build_local.sh (81%) rename setup_local.sh => bin/setup_local.sh (100%) create mode 100755 bin/up_local.sh diff --git a/build_github.sh b/bin/build_github.sh similarity index 78% rename from build_github.sh rename to bin/build_github.sh index 05b2684..23a1813 100755 --- a/build_github.sh +++ b/bin/build_github.sh @@ -12,6 +12,9 @@ fi source .env +export FRONTEND_BUILD_CONTEXT="https://${GH_TOKEN}@${FRONTEND_REPO_URL}#${FRONTEND_REF}" +export API_BUILD_CONTEXT="https://${GH_TOKEN}@${API_REPO_URL}#${API_REF}" +export BACKEND_BUILD_CONTEXT="https://${GH_TOKEN}@${BACKEND_REPO_URL}#${BACKEND_REF}" # Create temporary container to copy nginx config docker volume create project_nginx_conf diff --git a/build_local.sh b/bin/build_local.sh similarity index 81% rename from build_local.sh rename to bin/build_local.sh index d4a8694..0daa17e 100755 --- a/build_local.sh +++ b/bin/build_local.sh @@ -11,4 +11,4 @@ echo $API_BUILD_CONTEXT echo $BACKEND_BUILD_CONTEXT # Run Docker Compose -docker-compose --profile core -f docker-compose.local.yaml up --build -d +./bin/up_local.sh \ No newline at end of file diff --git a/setup_local.sh b/bin/setup_local.sh similarity index 100% rename from setup_local.sh rename to bin/setup_local.sh diff --git a/bin/up_local.sh b/bin/up_local.sh new file mode 100755 index 0000000..dd735e8 --- /dev/null +++ b/bin/up_local.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker-compose --profile core -f docker-compose.local.yaml up --build -d \ No newline at end of file From a21b51eaa2199a376c566101ff943d7af63ec4d6 Mon Sep 17 00:00:00 2001 From: Keith Perfetti Date: Wed, 23 Jul 2025 18:27:34 -0400 Subject: [PATCH 3/7] Including node_modules --- docker-compose.local.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.local.yaml b/docker-compose.local.yaml index 276d8e5..5184c61 100644 --- a/docker-compose.local.yaml +++ b/docker-compose.local.yaml @@ -5,12 +5,14 @@ services: service: frontend volumes: - ./repo_refs/react1-app:/app + - /app/node_modules backend: extends: file: docker-compose.yaml service: backend volumes: - ./repo_refs/react2-app:/app + - /app/node_modules api: extends: file: docker-compose.yaml From 12b9c18559a40fcf557cf0dc860055dd3e710d07 Mon Sep 17 00:00:00 2001 From: Keith Perfetti Date: Wed, 23 Jul 2025 18:30:32 -0400 Subject: [PATCH 4/7] Starting to update readme --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 784a8d9..bd20865 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,22 @@ Example for a blog post about nginx docker compose +## Prerequisites +- Github token with these repos in scope. + ## Setup +Set your environment variables & initialize submodules +```bash +cp .env.sample .env +source .env + +git submodule sync +git submodule update --init --recursive +``` + + + +## Build the Environments To run this you will execute one of the following commands depending on your build source: From 319b466c42203057bf5a28403cf5a5f92ca7fce5 Mon Sep 17 00:00:00 2001 From: Keith Perfetti Date: Wed, 23 Jul 2025 18:30:47 -0400 Subject: [PATCH 5/7] mainbump --- repo_refs/rails-app | 2 +- repo_refs/react1-app | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/repo_refs/rails-app b/repo_refs/rails-app index 6479f9e..d5226ec 160000 --- a/repo_refs/rails-app +++ b/repo_refs/rails-app @@ -1 +1 @@ -Subproject commit 6479f9e9a4a8041809a3b3f1ef1ac8359c8f665b +Subproject commit d5226ec9efa41f2b0447f40be4609f41281d2b0d diff --git a/repo_refs/react1-app b/repo_refs/react1-app index 5b47480..b8bbbc2 160000 --- a/repo_refs/react1-app +++ b/repo_refs/react1-app @@ -1 +1 @@ -Subproject commit 5b47480398e8c10f05e5d5220733b6d743cd9bc3 +Subproject commit b8bbbc2b9e501d359b3e0f1238883703987c02b0 From e9cd8a1db70841a98b7792b311e16fe043c6e898 Mon Sep 17 00:00:00 2001 From: Keith Perfetti Date: Wed, 23 Jul 2025 18:38:06 -0400 Subject: [PATCH 6/7] Fixing circleci --- .circleci/config.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f6d1b64..ad7b745 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ jobs: - setup_remote_docker: docker_layer_caching: true - run: ls -l $(ls) - - run: bash ./build_github.sh + - run: bash ./bin/build_github.sh - run: docker ps --format "table {{.Names}}\t{{.Ports}}" && docker compose ps - run: docker-compose up --build --no-deps -d test - run: docker compose exec test npx cypress run diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 002c6bd..af5891d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,7 +48,7 @@ jobs: submodules: false - name: Build and start Docker Compose services - run: bash ./build_github.sh + run: bash ./bin/build_github.sh - name: check dns is working run: cat /etc/hosts; netstat -tulpn # Use -tulpn to show TCP/UDP listeners From 39c7fd74eb15ad48293d047f8cfc310b4bda79a4 Mon Sep 17 00:00:00 2001 From: Keith Perfetti Date: Wed, 23 Jul 2025 18:42:51 -0400 Subject: [PATCH 7/7] fixing up the readme --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bd20865..5cd4136 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,10 @@ Example for a blog post about nginx docker compose ## Prerequisites -- Github token with these repos in scope. +- Github token with these repos in scope. `GH_TOKEN` +- `docker` +- `docker compose` +- `git` ## Setup Set your environment variables & initialize submodules @@ -16,7 +19,6 @@ git submodule update --init --recursive ``` - ## Build the Environments To run this you will execute one of the following commands depending on your build source: @@ -26,7 +28,7 @@ To run this you will execute one of the following commands depending on your bui To build from local directories, run: ```bash -./build_local.sh +./bin/build_local.sh ``` This setup allows for hot-swapping of code. Any changes made in the `repo_refs` directories will be immediately reflected in the running containers, allowing developers to see their changes in real-time via the nginx server. @@ -36,7 +38,7 @@ This setup allows for hot-swapping of code. Any changes made in the `repo_refs` To build from GitHub repositories, run: ```bash -./build_github.sh +./bin/build_github.sh ``` The GitHub build process is isolated from the local development environment, ensuring a clean and isolated build environment. This prevents any potential conflicts with local volumes.