Skip to content

Commit e9e2eab

Browse files
authored
Merge pull request #2 from perfetti/derusting_project
Fixing local development experience
2 parents 9d371f8 + 39c7fd7 commit e9e2eab

File tree

11 files changed

+34
-10
lines changed

11 files changed

+34
-10
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- setup_remote_docker:
1212
docker_layer_caching: true
1313
- run: ls -l $(ls)
14-
- run: bash ./build_github.sh
14+
- run: bash ./bin/build_github.sh
1515
- run: docker ps --format "table {{.Names}}\t{{.Ports}}" && docker compose ps
1616
- run: docker-compose up --build --no-deps -d test
1717
- run: docker compose exec test npx cypress run

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
submodules: false
4949

5050
- name: Build and start Docker Compose services
51-
run: bash ./build_github.sh
51+
run: bash ./bin/build_github.sh
5252

5353
- name: check dns is working
5454
run: cat /etc/hosts; netstat -tulpn # Use -tulpn to show TCP/UDP listeners

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[submodule "repo_refs/react1-app"]
22
path = repo_refs/react1-app
3-
url = ${FRONTEND_BUILD_CONTEXT}
3+
url = https://github.com/perfetti/react1-app.git
44
[submodule "repo_refs/react2-app"]
55
path = repo_refs/react2-app
6-
url = ${BACKEND_BUILD_CONTEXT}
6+
url = https://github.com/perfetti/react2-app.git
77
[submodule "repo_refs/rails-app"]
88
path = repo_refs/rails-app
9-
url = ${API_BUILD_CONTEXT}
9+
url = https://github.com/perfetti/rails-app.git

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,24 @@
22

33
Example for a blog post about nginx docker compose
44

5+
## Prerequisites
6+
- Github token with these repos in scope. `GH_TOKEN`
7+
- `docker`
8+
- `docker compose`
9+
- `git`
10+
511
## Setup
12+
Set your environment variables & initialize submodules
13+
```bash
14+
cp .env.sample .env
15+
source .env
16+
17+
git submodule sync
18+
git submodule update --init --recursive
19+
```
20+
21+
22+
## Build the Environments
623

724
To run this you will execute one of the following commands depending on your build source:
825

@@ -11,7 +28,7 @@ To run this you will execute one of the following commands depending on your bui
1128
To build from local directories, run:
1229

1330
```bash
14-
./build_local.sh
31+
./bin/build_local.sh
1532
```
1633

1734
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.
@@ -21,7 +38,7 @@ This setup allows for hot-swapping of code. Any changes made in the `repo_refs`
2138
To build from GitHub repositories, run:
2239

2340
```bash
24-
./build_github.sh
41+
./bin/build_github.sh
2542
```
2643

2744
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.

build_github.sh renamed to bin/build_github.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ fi
1212

1313
source .env
1414

15+
export FRONTEND_BUILD_CONTEXT="https://${GH_TOKEN}@${FRONTEND_REPO_URL}#${FRONTEND_REF}"
16+
export API_BUILD_CONTEXT="https://${GH_TOKEN}@${API_REPO_URL}#${API_REF}"
17+
export BACKEND_BUILD_CONTEXT="https://${GH_TOKEN}@${BACKEND_REPO_URL}#${BACKEND_REF}"
1518

1619
# Create temporary container to copy nginx config
1720
docker volume create project_nginx_conf

build_local.sh renamed to bin/build_local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ echo $API_BUILD_CONTEXT
1111
echo $BACKEND_BUILD_CONTEXT
1212

1313
# Run Docker Compose
14-
docker-compose --profile core -f docker-compose.local.yaml up --build -d
14+
./bin/up_local.sh
File renamed without changes.

bin/up_local.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
docker-compose --profile core -f docker-compose.local.yaml up --build -d

docker-compose.local.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ services:
55
service: frontend
66
volumes:
77
- ./repo_refs/react1-app:/app
8+
- /app/node_modules
89
backend:
910
extends:
1011
file: docker-compose.yaml
1112
service: backend
1213
volumes:
1314
- ./repo_refs/react2-app:/app
15+
- /app/node_modules
1416
api:
1517
extends:
1618
file: docker-compose.yaml

repo_refs/rails-app

0 commit comments

Comments
 (0)