Skip to content

Commit e2fd046

Browse files
Refactor: Cleanup extra and redundant swarm related files
1 parent 54efff2 commit e2fd046

19 files changed

Lines changed: 37 additions & 1482 deletions

.github/workflows/build-and-deploy.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ jobs:
8484
- uses: actions/checkout@v4
8585

8686
- name: Free disk space
87-
# Reclaims ~25-35 GB on ubuntu-latest. Consider re-pinning to a commit SHA for supply-chain hardening.
87+
# Reclaims ~25-35 GB on ubuntu-latest.
8888
uses: jlumbroso/free-disk-space@v1.3.1
8989
with:
9090
tool-cache: true
91-
large-packages: false # apt purge is slow; tool-cache + dotnet/android give the most back
92-
docker-images: false # we need docker working
91+
large-packages: false
92+
docker-images: false
9393

9494
- name: Log in to GHCR
9595
if: env.PUSH == 'true'
@@ -221,8 +221,6 @@ jobs:
221221
KUBECONFIG_DATA: ${{ secrets.KUBECONFIG }}
222222
run: |
223223
set -euo pipefail
224-
# Store the KUBECONFIG secret (raw YAML) via env to avoid shell-injection/quoting issues.
225-
# If your secret is base64-encoded, replace the printf line with: printf '%s' "$KUBECONFIG_DATA" | base64 -d > ...
226224
printf '%s' "$KUBECONFIG_DATA" > "$RUNNER_TEMP/kubeconfig"
227225
chmod 600 "$RUNNER_TEMP/kubeconfig"
228226
echo "KUBECONFIG=$RUNNER_TEMP/kubeconfig" >> "$GITHUB_ENV"

.github/workflows/release-bot.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
steps:
1111
- name: Checkout repo
1212
uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
1315
- name: Create output folder
1416
run: mkdir -p ${{ github.workspace }}/checklist_items
1517
- name: Write checklist items to files
@@ -38,12 +40,18 @@ jobs:
3840
3941
- name: Collect checklist items
4042
run: |
41-
msg=$(awk 'FNR==1 && NR!=1 {print "---"}{print}' checklist_items/*.log)
42-
echo "$msg" >> aggregated.log
43-
sha="*SHA: ${{ github.event.pull_request.head.sha }}*"
44-
sed -i "1i\\
45-
$sha
46-
" aggregated.log
43+
set -o pipefail
44+
shopt -s nullglob
45+
files=(checklist_items/*.log)
46+
{
47+
echo "*SHA: ${{ github.event.pull_request.head.sha }}*"
48+
echo
49+
if [ ${#files[@]} -eq 0 ]; then
50+
echo "_No merge-commit checklist items found ahead of \`master\`._"
51+
else
52+
awk 'FNR==1 && NR!=1 {print "---"}{print}' "${files[@]}"
53+
fi
54+
} > aggregated.log
4755
4856
- name: Update Pull Request
4957
uses: actions/github-script@v5

Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

Makefile

Lines changed: 12 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# TODO: Some of these should be converted into Ansible Playbooks when there's time.
2-
3-
# Chose a makefile because its easier to read over a bunch of if statements inside a bash script.
4-
# We are taking advantage of .PHONY that is available in makefiles to create this simple looking
5-
# list of command shortcuts
1+
# Local-development shortcuts (docker-compose).
2+
#
3+
# Image build/push and cluster deploy now live in .github/workflows/build-and-deploy.yml
4+
# (builds to GHCR, deploys to the k3s `rodan` namespace). The old Docker Swarm / DockerHub
5+
# targets were removed when Rodan migrated to k3s.
66

77
# Portable replacement for `sed` or `gsed`
88
# See https://unix.stackexchange.com/questions/92895/how-can-i-achieve-portability-with-sed-i-in-place-editing
@@ -11,179 +11,27 @@ REPLACE := perl -i -pe
1111
RODAN_PATH := ./rodan-main/code/rodan
1212
JOBS_PATH := $(RODAN_PATH)/jobs
1313

14-
PROD_TAG := v3.3.1
15-
1614
DOCKER_TAG := nightly
1715

18-
# Individual Commands
19-
2016
build:
2117
@echo "[-] Rebuilding Docker Images for Rodan..."
22-
# Build py3-celery, because it's needed for Rodan and Celery images
23-
# @docker-compose -f build.yml build --no-cache py3-celery # Sometimes it's better to use the
24-
# no-cache option if something unexplicably broke with the py3-celery image (a cached build step perhaps)
18+
# py3-celery first — rodan-main (the `rodan` service) and celery images are FROM it.
2519
@docker compose -f build.yml build --no-cache py3-celery
26-
# Build rodan and rodan-client because they are needed for nginx
20+
# rodan(-main) and rodan-client next — nginx is FROM rodan-main.
2721
@docker compose -f build.yml build --no-cache --parallel rodan rodan-client
28-
# DockerHub is not intuitive. You won't be able to build from the source root folder in both build contextes.
29-
# When you build locally, the COPY command is relative to the dockerfile. When you build on DockerHub, its relative to the source root.
30-
# For this reason we replace the name to build locally because we build more often on DockerHub than on local.
31-
@$(REPLACE) "s/COPY .\/postgres\/maintenance/COPY .\/maintenance/g" ./postgres/Dockerfile || $(REPLACE) "s/COPY .\/postgres\/maintenance/COPY .\/maintenance/g" ./postgres/Dockerfile
32-
@docker compose -f build.yml build --no-cache --parallel nginx gpu-celery postgres hpc-rabbitmq
33-
# Revert back the change to the COPY command so it will work on Docker Hub.
34-
@$(REPLACE) "s/COPY .\/maintenance/COPY .\/postgres\/maintenance/g" ./postgres/Dockerfile || $(REPLACE) "s/COPY .\/maintenance/COPY .\/postgres\/maintenance/g" ./postgres/Dockerfile
22+
@docker compose -f build.yml build --no-cache --parallel nginx gpu-celery postgres
3523
@echo "[+] Done."
3624

37-
backup_db:
38-
@docker exec `docker ps -f name=rodan_postgres -q` backup
39-
40-
restore_db:
41-
@docker exec `docker ps -f name=rodan_postgres -q` restore
42-
43-
# Keep in mind, you may need to deal with the postgres/maintenance/backup or backups files depending on setup
44-
4525
run: remote_jobs
4626
# Run local version for dev
47-
# Hello, 2022 hires!
4827
@DOCKER_TAG=$(DOCKER_TAG) docker compose up
4928

50-
test_prod: pull_prod
51-
# Test production Rodan images with specified tag
52-
# May want to change test-prod-compose.yml if you want a
53-
# different tag.
54-
docker compose -f test-prod-compose.yml up
55-
5629
run_client:
5730
# Run Rodan-Client for dev (needs local dev up and running)
5831
@docker run -p 8080:9002 -v `pwd`/rodan-client/code:/code ddmal/rodan-client:nightly bash
5932

60-
deploy_staging:
61-
# Can also be used to update a configuration (point to a different image.)
62-
@echo "[-] Deploying Docker Swarm for: Rodan Staging"
63-
@docker stack deploy --prune --with-registry-auth -c staging.yml rodan
64-
@echo "[+] Done."
65-
66-
deploy_production:
67-
# Can also be used to update a configuration (point to a different image.)
68-
@echo "[-] Deploying Docker Swarm for: Rodan Production"
69-
@docker stack deploy --with-registry-auth -c production.yml rodan
70-
@echo "[+] Done."
71-
72-
copy_docker_tag:
73-
# tag=v1.5.0rc0 make copy_docker_tag
74-
@docker image tag $(docker images ddmal/rodan:nightly -q) ddmal/rodan:$(tag)
75-
@docker image tag $(docker images ddmal/rodan-python3-celery:nightly -q) ddmal/rodan-python3-celery:$(tag)
76-
@docker image tag $(docker images ddmal/rodan-gpu-celery:nightly -q) ddmal/rodan-gpu-celery:$(tag)
77-
78-
pull_prod:
79-
docker pull ddmal/iipsrv:nightly
80-
docker pull ddmal/nginx:$(PROD_TAG)
81-
docker pull ddmal/postgres-plpython:$(PROD_TAG)
82-
docker pull ddmal/rodan-gpu-celery:$(PROD_TAG)
83-
docker pull ddmal/rodan-main:$(PROD_TAG)
84-
docker pull ddmal/rodan-python3-celery:$(PROD_TAG)
85-
docker pull rabbitmq:alpine
86-
docker pull redis:alpine
87-
88-
pull_docker_tag:
89-
# tag=v1.5.0rc0 make pull_docker_tag
90-
@docker pull ddmal/rodan:$(tag)
91-
@docker pull ddmal/rodan-python3-celery:$(tag)
92-
@docker pull ddmal/rodan-gpu-celery:$(tag)
93-
94-
push_docker_tag:
95-
# tag=v1.5.0rc0 make push_docker_tag
96-
@docker push ddmal/rodan:$(tag)
97-
@docker push ddmal/rodan-python3-celery:$(tag)
98-
@docker push ddmal/rodan-gpu-celery:$(tag)
99-
100-
update:
101-
# tag1=v1.5.0rc0 tag2=v1.3.1 make update
102-
# This will update the nightly images forcefully
103-
@echo "[-] Updating Docker Swarm images..."
104-
# @docker-compose pull
105-
106-
# DB First
107-
@docker service update \
108-
--force \
109-
--update-order start-first \
110-
--update-delay 30s \
111-
--image ddmal/postgres-plpython:$(tag2) \
112-
rodan_postgres
113-
114-
# You need to be logged in to docker for this one.
115-
@docker service update \
116-
--force \
117-
--with-registry-auth \
118-
--update-order start-first \
119-
--update-delay 10m \
120-
--image ddmal/rodan:$(tag1) \
121-
rodan_rodan-main
122-
123-
# These images might need time to update.
124-
@docker service update \
125-
--force \
126-
--with-registry-auth \
127-
--update-order start-first \
128-
--stop-grace-period 9h \
129-
--update-delay 10m \
130-
--image ddmal/rodan:$(tag1) \
131-
rodan_celery
132-
# These are public images
133-
@docker service update \
134-
--force \
135-
--update-order start-first \
136-
--stop-grace-period 9h \
137-
--update-delay 30s \
138-
--image ddmal/rodan-python3-celery:$(tag1) \
139-
rodan_py3-celery
140-
@docker service update \
141-
--force \
142-
--update-order start-first \
143-
--stop-grace-period 9h \
144-
--update-delay 30s \
145-
--image ddmal/rodan-gpu-celery:$(tag1) \
146-
rodan_gpu-celery
147-
148-
# # TODO: Need to make rabbitmq durable and permanent
149-
# # before we can make rolling updates for rabbitmq/hpc-rabbitmq.
150-
# @docker service update \
151-
# --force \
152-
# --update-order start-first \
153-
# --update-delay 30s \
154-
# --image ddmal/hpc-rabbitmq:$(tag2) \
155-
# rodan_hpc-rabbitmq
156-
@docker service update \
157-
--force \
158-
--update-order start-first \
159-
--update-delay 30s \
160-
--image ddmal/nginx:$(tag2) \
161-
rodan_nginx
162-
163-
@echo "[+] Done."
164-
165-
scale:
166-
@docker service scale rodan_nginx=$(num)
167-
@docker service scale rodan_rodan=$(num)
168-
@docker service scale rodan_celery=$(num)
169-
@docker service scale rodan_py3-celery=$(num)
170-
# @docker service scale rodan_gpu-celery=$(num)
171-
@docker service scale rodan_redis=$(num)
172-
# @docker service scale rodan_postgres=$(num)
173-
@docker service scale rodan_rabbitmq=$(num)
174-
175-
health:
176-
@docker inspect --format "{{json .State.Health }}" $(log) | jq
177-
178-
renew_certbot:
179-
@docker exec `docker ps -f name=rodan_nginx -q` certbot renew --no-random-sleep-on-renew
180-
@docker exec `docker ps -f name=rodan_nginx -q` nginx -s reload
181-
18233
stop:
183-
# This is the same command to stop docker swarm or docker compose
184-
@echo "[-] Stopping all running docker containers and services..."
185-
@docker service rm `docker service ls -q` >>/dev/null 2>&1 || echo "[+] No Services Running"
186-
# @docker stop `docker ps -aq` >>/dev/null 2>&1 || echo "[+] No Containers Running"
34+
@echo "[-] Stopping all running docker containers..."
18735
@docker stop `docker ps -aq | grep -v $$(docker ps -aq --filter "name=gpu_dont_kill_me")` >>/dev/null 2>&1 || echo "[+] No Containers Running"
18836
@echo "[+] Done."
18937

@@ -199,29 +47,8 @@ clean_git:
19947
@git pull
20048
@echo "[+] Done."
20149

202-
203-
clean_swarm:
204-
# Not usually needed, but this will restart the swarm
205-
@echo "[-] Exiting from Docker Swarm and recreating new Swarm Manager..."
206-
@docker stack rm rodan || echo "[-] No stack to remove"
207-
@docker swarm leave --force || echo "[-] Not a swarm manager"
208-
@docker swarm init
209-
@echo "[+] Done."
210-
211-
debug_swarm:
212-
@echo "[+] Creating a live service in the same network."
213-
@docker service create --name statefulservice --network rodan_default --entrypoint="bash -c 'tail -f /dev/null'" --env-file=./scripts/staging.env ddmal/rodan:nightly bash
214-
@docker exec -it `docker ps -f name=statefulservice -q` bash
215-
216-
push:
217-
@echo "[-] Pushing images to Docker Hub..."
218-
@docker compose push
219-
@echo "[+] Done."
220-
221-
pull:
222-
@echo "[-] Pulling docker images from Docker Hub..."
223-
@DOCKER_TAG=$(DOCKER_TAG) docker compose pull
224-
@echo "[+] Done."
50+
health:
51+
@docker inspect --format "{{json .State.Health }}" $(log) | jq
22552

22653
$(JOBS_PATH)/neon_wrapper/Neon/package.json:
22754
@cd $(JOBS_PATH); \
@@ -235,32 +62,9 @@ $(JOBS_PATH)/neon_wrapper/static/editor.html: $(JOBS_PATH)/neon_wrapper/Neon/pac
23562
$(JOBS_PATH)/pixel_wrapper/package.json:
23663
@cd $(JOBS_PATH); git clone --recurse-submodules -b develop https://github.com/DDMAL/pixel_wrapper.git
23764

238-
remote_jobs: $(JOBS_PATH)/pixel_wrapper/package.json $(JOBS_PATH)/neon_wrapper/static/editor.html
65+
remote_jobs: $(JOBS_PATH)/pixel_wrapper/package.json $(JOBS_PATH)/neon_wrapper/static/editor.html
23966
@cd $(RODAN_PATH); $(REPLACE) "s/#py3 //g" ./settings.py
24067
@cd $(RODAN_PATH); $(REPLACE) "s/#gpu //g" ./settings.py
24168

242-
gpu-celery_log:
243-
@docker exec $$(docker ps -f name=rodan_gpu-celery --format "{{.ID}}") tail -f /code/Rodan/rodan-celery-GPU.log
244-
245-
py3-celery_log:
246-
@docker exec $$(docker ps -f name=rodan_py3-celery --format "{{.ID}}") tail -f /code/Rodan/rodan-celery-Python3.log
247-
248-
celery_log:
249-
@docker exec $$(docker ps -f name=rodan_celery --format "{{.ID}}") tail -f /code/Rodan/rodan-celery-celery.log
250-
251-
rodan-main_log:
252-
@docker exec $$(docker ps -f name=rodan_rodan-main --format "{{.ID}}") tail -f /code/Rodan/rodan.log
253-
254-
update_prod_version_tag:
255-
# old_tag=v2.x.x make update_prod_version_name
256-
@$(REPLACE) "s/$(old_tag)/$(PROD_TAG)/g" ./production.yml
257-
@$(REPLACE) "s/$(old_tag)/$(PROD_TAG)/g" ./rodan-main/code/rodan/__init__.py
258-
25969
# Command Groups
260-
reset: stop clean pull run
26170
clean_reset: stop clean build run
262-
upload: clean_reset push
263-
deploy: clean_git pull run_swarm
264-
reset_swarm: stop clean_git clean_swarm clean pull deploy_staging
265-
update_swarm: clean_git update
266-
staging: stop clean pull deploy_staging

build.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ services:
55
build:
66
context: ./nginx
77
dockerfile: Dockerfile
8+
args:
9+
VERSION: nightly
810
image: "ddmal/nginx:nightly"
911

1012
iipsrv:
1113
build:
1214
context: ./iipsrv
1315
dockerfile: Dockerfile
1416
image: "ddmal/iipsrv:nightly"
15-
17+
1618
rodan:
1719
build:
1820
context: .
19-
dockerfile: Dockerfile
21+
dockerfile: rodan-main/Dockerfile
2022
args:
2123
BRANCHES: develop
22-
image: "ddmal/rodan:nightly"
24+
VERSION: nightly
25+
image: "ddmal/rodan-main:nightly"
2326

2427
py3-celery:
2528
build:
@@ -39,13 +42,12 @@ services:
3942

4043
postgres:
4144
build:
42-
context: ./postgres
43-
dockerfile: Dockerfile
45+
context: .
46+
dockerfile: ./postgres/Dockerfile
4447
image: "ddmal/postgres-plpython:nightly"
4548

4649
rodan-client:
4750
build:
4851
context: ./rodan-client
4952
dockerfile: Dockerfile
5053
image: "ddmal/rodan-client:nightly"
51-

0 commit comments

Comments
 (0)