Skip to content

Commit

Permalink
chore: start experimenting with scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
luandro committed Jun 17, 2024
1 parent 78a4727 commit ef56a00
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.balena/

*.md
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

.docker
# Runtime data
pids
*.pid
Expand Down
20 changes: 20 additions & 0 deletions docker-stacks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
demo:
exclude:
labels:
services:
- python-wifi-connect
- balena-interface
volumes:
- wifi_db
include:
services:
- portal: 80
environment:
- BALENA_INTERFACE_API=http://
local:
exclude:
labels:
services:
- balena-interface
volumes:
- interface_db
5 changes: 5 additions & 0 deletions scripts/.docker/docker-compose-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
portal:
ports:
- 80:80
environment:
- BALENA_INTERFACE_API=http://
5 changes: 5 additions & 0 deletions scripts/.docker/docker-compose-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
portal:
ports:
- 80:80
environment:
- BALENA_INTERFACE_API=http://balena-interface
90 changes: 90 additions & 0 deletions scripts/generate-docker-stacks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/sh

# Ensure .docker directory exists
mkdir -p .docker

# Read config file
config=$(cat ../docker-stacks.yml)

# Parse YAML
demo_config=$(echo $config | yq .demo)
local_config=$(echo $config | yq .local)

# Demo environment
# Exclude services
sed "/python-wifi-connect/d" docker-compose.yml > .docker/docker-compose-demo.yml
# Exclude volumes
sed -i "/wifi_db/d" .docker/docker-compose-demo.yml
# Include services
echo " portal:
ports:
- 80:80" >> .docker/docker-compose-demo.yml
# Include environment
echo " environment:" >> .docker/docker-compose-demo.yml
echo " - BALENA_INTERFACE_API=http://" >> .docker/docker-compose-demo.yml

# Local environment
# Exclude services
sed "/balena-interface/d" docker-compose.yml > .docker/docker-compose-local.yml
# Exclude volumes
sed -i "/interface_db/d" .docker/docker-compose-local.yml
# Include services
echo " portal:
ports:
- 80:80" >> .docker/docker-compose-local.yml
# Include environment
echo " environment:" >> .docker/docker-compose-local.yml
echo " - BALENA_INTERFACE_API=http://balena-interface" >> .docker/docker-compose-local.yml
# #!/bin/sh

# # Read docker-compose.yml
# # Read balena.yml file
# # Read docker-stacks.yml
# # Parse YAML
# # For each environment
# # 1. Exclude: labels, services, environments
# # 2. Include: labels, environments
# # TODO: include services

# # Read config file
# config=$(cat ../docker-stacks.yml)

# # Parse YAML
# demo_config=$(echo $config | yq .demo)
# local_config=$(echo $config | yq .local)

# # Demo environment
# # Exclude services
# sed -i "/python-wifi-connect/d" docker-compose.yml
# # Exclude volumes
# sed -i "/wifi_db/d" docker-compose.yml
# # Include services
# echo " portal:
# ports:
# - 80:80" >> docker-compose.yml
# # Include environment
# echo " environment:" >> docker-compose.yml
# echo " - BALENA_INTERFACE_API=http://" >> docker-compose.yml

# # Local environment
# # Exclude services
# sed -i "/balena-interface/d" docker-compose.yml
# # Exclude volumes
# sed -i "/interface_db/d" docker-compose.yml
# # Include services
# echo " portal:
# ports:
# - 80:80" >> docker-compose.yml
# # Include environment
# echo " environment:" >> docker-compose.yml
# echo " - BALENA_INTERFACE_API=http://balena-interface" >> docker-compose.yml

# # This script:

# # Reads the docker-stacks.yml config file
# # Parses the YAML using yq to get the demo and local environment configs
# # For the demo environment, it excludes the python-wifi-connect service and wifi_db volume
# # It includes the portal service and BALENA_INTERFACE_API environment variable
# # For the local environment, it excludes the balena-interface service and interface_db volume
# # It includes the portal service and BALENA_INTERFACE_API environment variable pointing to balena-interface
# # It modifies the docker-compose.yml file based on these inclusions and exclusions

0 comments on commit ef56a00

Please sign in to comment.