Skip to content

Fixing local development experience #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

Example for a blog post about nginx docker compose

## Prerequisites
- Github token with these repos in scope. `GH_TOKEN`
- `docker`
- `docker compose`
- `git`

## 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:

Expand All @@ -11,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.
Expand All @@ -21,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.
Expand Down
3 changes: 3 additions & 0 deletions build_github.sh → bin/build_github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build_local.sh → bin/build_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
2 changes: 2 additions & 0 deletions bin/up_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker-compose --profile core -f docker-compose.local.yaml up --build -d
2 changes: 2 additions & 0 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion repo_refs/rails-app
2 changes: 1 addition & 1 deletion repo_refs/react1-app
Loading