Skip to content

Commit f3158a5

Browse files
committed
updated testing script & added workflow for nginx
Changed nginx build to rely on local build, now only builds caches ui and nginx containers. upload_flat_folder_of_dicoms.py always uploads to localhost (for now) since that's where it's testing, and lastly setup test-upload-nginx.yml to run nginx testing on github actions
1 parent d55b1bf commit f3158a5

File tree

6 files changed

+220
-152
lines changed

6 files changed

+220
-152
lines changed
Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
name: Docker Build (Nginx)
22

33
on:
4+
workflow_run:
5+
workflows: ["Docker Build (Local)"]
6+
types:
7+
- completed
48
push:
59
branches: [ '*' ]
610
pull_request:
711
branches: [ '*' ]
12+
workflow_dispatch:
813

914
env:
1015
DOCKER_BUILDKIT: 1
@@ -15,45 +20,51 @@ env:
1520
jobs:
1621
build:
1722
runs-on: ubuntu-latest
18-
outputs:
19-
images: ${{ steps.save-images.outputs.images }}
2023
steps:
2124
- uses: actions/checkout@v4
2225

2326
- name: Set repository name
2427
id: repo
2528
run: echo "REPO_NAME=$(basename $GITHUB_WORKSPACE)" >> $GITHUB_ENV
2629

27-
- name: Pull required images
28-
run: docker compose -f ${{ env.COMPOSE_FILE }} pull
30+
- name: Cache Docker images
31+
uses: actions/cache@v4
32+
id: docker-cache
33+
with:
34+
path: |
35+
mongo.tar
36+
api.tar
37+
handler.tar
38+
key: docker-local-images-${{ github.sha }}
39+
restore-keys: |
40+
docker-local-images-
41+
42+
- name: Load cached images
43+
if: steps.docker-cache.outputs.cache-hit == 'true'
44+
run: |
45+
# Load images and verify they were loaded successfully
46+
docker load < mongo.tar || exit 1
47+
rm mongo.tar
48+
docker load < api.tar || exit 1
49+
rm api.tar
50+
docker load < handler.tar || exit 1
51+
rm handler.tar
2952
30-
- name: Build services
31-
run: docker compose -f ${{ env.COMPOSE_FILE }} build
53+
- name: Build UI with nginx
54+
run: docker compose -f ${{ env.COMPOSE_FILE }} build ui
3255

3356
- name: Save images
34-
id: save-images
3557
run: |
36-
# Save images to tar files
37-
docker save mongo > mongo.tar
38-
docker save nginx > nginx.tar
39-
docker save ${REGISTRY_PREFIX}/${REPO_NAME}-api:latest > api-nginx.tar
40-
docker save ${REGISTRY_PREFIX}/${REPO_NAME}-handler:latest > handler-nginx.tar
58+
# Save all ui and nginximages to tar files
4159
docker save ${REGISTRY_PREFIX}/${REPO_NAME}-ui:latest > ui-nginx.tar
42-
43-
# Upload as artifacts
44-
echo "images=mongo.tar,api-nginx.tar,handler-nginx.tar,ui-nginx.tar,nginx.tar" >> $GITHUB_OUTPUT
45-
46-
- name: Upload images
47-
uses: actions/upload-artifact@v4
60+
docker save nginx > nginx.tar
61+
62+
- name: Cache Docker images
63+
uses: actions/cache@v4
4864
with:
49-
name: docker-images-nginx
5065
path: |
51-
mongo.tar
52-
api-nginx.tar
53-
handler-nginx.tar
5466
ui-nginx.tar
5567
nginx.tar
56-
retention-days: 1
57-
58-
- name: Clean up
59-
run: docker system prune -f
68+
key: docker-nginx-images-${{ github.sha }}
69+
restore-keys: |
70+
docker-nginx-images-
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Test Nginx Upload
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Docker Build (Nginx)"]
6+
types:
7+
- completed
8+
workflow_dispatch: # Allow manual triggering
9+
10+
jobs:
11+
Test-Nginx-Uploads:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
14+
15+
env:
16+
COMPOSE_FILE: ./docker-compose-nginx.yml
17+
REGISTRY_PREFIX: docker.io/library
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: true # Ensure we get the submodule info
23+
24+
- name: Set repository name
25+
run: echo "REPO_NAME=$(basename $GITHUB_WORKSPACE)" >> $GITHUB_ENV
26+
27+
- name: Cache test data
28+
uses: actions/cache@v4
29+
id: test-data-cache
30+
with:
31+
path: test/test_data
32+
key: test-data-${{ hashFiles('.gitmodules') }}
33+
restore-keys: |
34+
test-data-
35+
36+
- name: Get test data if not cached
37+
if: steps.test-data-cache.outputs.cache-hit != 'true'
38+
run: |
39+
make get-test-data
40+
41+
- name: Cache Docker images
42+
uses: actions/cache@v4
43+
id: docker-cache
44+
with:
45+
path: |
46+
mongo.tar
47+
api.tar
48+
handler.tar
49+
key: docker-local-images-${{ github.event.workflow_run.head_sha || github.sha }}
50+
restore-keys: |
51+
docker-local-images-
52+
53+
- name: Cache Nginx images
54+
uses: actions/cache@v4
55+
id: nginx-cache
56+
with:
57+
path: |
58+
ui-nginx.tar
59+
nginx.tar
60+
key: docker-nginx-images-${{ github.event.workflow_run.head_sha || github.sha }}
61+
restore-keys: |
62+
docker-nginx-images-
63+
64+
- name: Load images
65+
run: |
66+
# Load base images
67+
docker load < mongo.tar || exit 1
68+
rm mongo.tar
69+
docker load < api.tar || exit 1
70+
# Tag the API image to match docker-compose
71+
docker tag ${REGISTRY_PREFIX}/${REPO_NAME}-api:latest api:latest
72+
rm api.tar
73+
docker load < handler.tar || exit 1
74+
# Tag the handler image to match docker-compose
75+
docker tag ${REGISTRY_PREFIX}/${REPO_NAME}-handler:latest handler:latest
76+
rm handler.tar
77+
78+
# Load nginx images
79+
docker load < ui-nginx.tar || exit 1
80+
# Tag the UI image to match docker-compose
81+
docker tag ${REGISTRY_PREFIX}/${REPO_NAME}-ui:latest ui:latest
82+
rm ui-nginx.tar
83+
docker load < nginx.tar || exit 1
84+
rm nginx.tar
85+
86+
- name: Do additional Nginx setup
87+
run: |
88+
# create self signed certs using the hostname
89+
./create_self_signed_certs.sh localhost
90+
91+
# copy the example.env to .env
92+
cp example.env .env
93+
94+
# Update .env to use the hostname
95+
sed -i "s/SERVER_NAME=.*/SERVER_NAME=localhost" .env
96+
sed -i "s/BRAINLIFE_USE_NGINX=.*/BRAINLIFE_USE_NGINX=true/" .env
97+
98+
- name: Start services
99+
run: |
100+
# Create and set permissions for temp directory
101+
mkdir -p /tmp/ezbids-workdir
102+
chmod 770 /tmp/ezbids-workdir
103+
104+
# Start services using our tagged images
105+
./launch.sh --daemon
106+
sleep 30
107+
108+
- name: Install uv
109+
run: |
110+
curl -LsSf https://astral.sh/uv/install.sh | sh
111+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
112+
113+
- name: Verify uv installation
114+
run: uv --version
115+
116+
- name: Run upload test
117+
run: |
118+
make test-upload

docker-compose-nginx.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ services:
6969
environment:
7070
VITE_APIHOST: https://${SERVER_NAME}/api
7171
VITE_BRAINLIFE_AUTHENTICATION: ${BRAINLIFE_AUTHENTICATION:-false}
72+
BRAINLIFE_USE_NGINX: true
7273
volumes:
7374
- ui_dist:/ui/dist
7475
command: tail -f /dev/null # Keep container running

docker-compose-production.yml

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

launch.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@
1111
# script to automatically generate and locate those certificates into the nginx/ssl/
1212
# folder.
1313

14+
# Parse command line arguments
15+
DAEMON_MODE=false
16+
while [[ $# -gt 0 ]]; do
17+
case $1 in
18+
-d|--daemon)
19+
DAEMON_MODE=true
20+
shift
21+
;;
22+
*)
23+
echo "Unknown option: $1"
24+
exit 1
25+
;;
26+
esac
27+
done
28+
1429
# check to see if a .env file exists
1530
if [ -f .env ]; then
1631
echo ".env file exists, loading environment variables from .env file"
@@ -93,8 +108,16 @@ fi
93108
# ok docker compose is now included in docker as an option for docker
94109
if [[ $(command -v docker-compose) ]]; then
95110
# if the older version is installed use the dash
96-
docker-compose --file ${DOCKER_COMPOSE_FILE} up
111+
if [ "$DAEMON_MODE" = true ]; then
112+
docker-compose --file ${DOCKER_COMPOSE_FILE} up -d
113+
else
114+
docker-compose --file ${DOCKER_COMPOSE_FILE} up
115+
fi
97116
else
98117
# if the newer version is installed don't use the dash
99-
docker compose --file ${DOCKER_COMPOSE_FILE} up
118+
if [ "$DAEMON_MODE" = true ]; then
119+
docker compose --file ${DOCKER_COMPOSE_FILE} up -d
120+
else
121+
docker compose --file ${DOCKER_COMPOSE_FILE} up
122+
fi
100123
fi

0 commit comments

Comments
 (0)