Skip to content

Commit 9f26f63

Browse files
committed
added docker build workflows
1 parent 9b76691 commit 9f26f63

File tree

5 files changed

+172
-3
lines changed

5 files changed

+172
-3
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Docker Build (Local)
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
env:
10+
DOCKER_BUILDKIT: 1
11+
COMPOSE_DOCKER_CLI_BUILD: 1
12+
COMPOSE_FILE: ./docker-compose.yml
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
images: ${{ steps.save-images.outputs.images }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Pull MongoDB
26+
run: docker pull mongo:4.4.15
27+
28+
- name: Build API
29+
uses: docker/build-push-action@v5
30+
with:
31+
context: .
32+
file: ${{ env.COMPOSE_FILE }}
33+
target: api
34+
load: true
35+
tags: ezbids-api:test
36+
37+
- name: Build Handler
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: .
41+
file: ${{ env.COMPOSE_FILE }}
42+
target: handler
43+
load: true
44+
tags: ezbids-handler:test
45+
46+
- name: Build UI
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: .
50+
file: ${{ env.COMPOSE_FILE }}
51+
target: ui
52+
load: true
53+
tags: ezbids-ui:test
54+
55+
- name: Save images
56+
id: save-images
57+
run: |
58+
# Save images to tar files
59+
docker save mongo:4.4.15 > mongo.tar
60+
docker save ezbids-api:test > api.tar
61+
docker save ezbids-handler:test > handler.tar
62+
docker save ezbids-ui:test > ui.tar
63+
64+
# Upload as artifacts
65+
echo "images=mongo.tar,api.tar,handler.tar,ui.tar" >> $GITHUB_OUTPUT
66+
67+
- name: Upload images
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: docker-images-local
71+
path: |
72+
mongo.tar
73+
api.tar
74+
handler.tar
75+
ui.tar
76+
retention-days: 1
77+
78+
- name: Clean up
79+
run: docker system prune -f
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Docker Build (Nginx)
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
env:
10+
DOCKER_BUILDKIT: 1
11+
COMPOSE_DOCKER_CLI_BUILD: 1
12+
COMPOSE_FILE: ./docker-compose-nginx.yml
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
images: ${{ steps.save-images.outputs.images }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Pull MongoDB
26+
run: docker pull mongo:4.4.15
27+
28+
- name: Build API
29+
uses: docker/build-push-action@v5
30+
with:
31+
context: .
32+
file: ${{ env.COMPOSE_FILE }}
33+
target: api
34+
load: true
35+
tags: ezbids-api-nginx:test
36+
37+
- name: Build Handler
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: .
41+
file: ${{ env.COMPOSE_FILE }}
42+
target: handler
43+
load: true
44+
tags: ezbids-handler-nginx:test
45+
46+
- name: Build UI
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: ./ui
50+
file: ./ui/Dockerfile-nginx
51+
load: true
52+
tags: ezbids-ui-nginx:test
53+
54+
- name: Build Nginx
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: .
58+
file: ${{ env.COMPOSE_FILE }}
59+
target: nginx
60+
load: true
61+
tags: ezbids-nginx:test
62+
63+
- name: Save images
64+
id: save-images
65+
run: |
66+
# Save images to tar files
67+
docker save mongo:4.4.15 > mongo.tar
68+
docker save ezbids-api-nginx:test > api-nginx.tar
69+
docker save ezbids-handler-nginx:test > handler-nginx.tar
70+
docker save ezbids-ui-nginx:test > ui-nginx.tar
71+
docker save ezbids-nginx:test > nginx.tar
72+
73+
# Upload as artifacts
74+
echo "images=mongo.tar,api-nginx.tar,handler-nginx.tar,ui-nginx.tar,nginx.tar" >> $GITHUB_OUTPUT
75+
76+
- name: Upload images
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: docker-images-nginx
80+
path: |
81+
mongo.tar
82+
api-nginx.tar
83+
handler-nginx.tar
84+
ui-nginx.tar
85+
nginx.tar
86+
retention-days: 1
87+
88+
- name: Clean up
89+
run: docker system prune -f

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
The secure, cloud-based service for the semi-automated mapping of entire sessions of neuroimaging data to the Brain Imaging Data Structure ([BIDS](https://bids.neuroimaging.io/)) standard.
44

5+
[![Docker Build (Local)](https://github.com/brainlife/ezbids/actions/workflows/docker-build-local.yml/badge.svg)](https://github.com/brainlife/ezbids/actions/workflows/docker-build-local.yml)
6+
[![Docker Build (Nginx)](https://github.com/brainlife/ezbids/actions/workflows/docker-build-nginx.yml/badge.svg)](https://github.com/brainlife/ezbids/actions/workflows/docker-build-nginx.yml)
7+
58
<img width="1450" alt="Screenshot 2023-11-01 at 11 50 48 AM" src="https://github.com/brainlife/ezbids/assets/2119795/2c054297-1503-4ebb-8718-336012c80b48">
69

710
### About

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ services:
6565

6666
ui:
6767
container_name: brainlife_ezbids-ui
68-
env_file:
69-
- .env
7068
build: ./ui
7169
platform: linux/amd64
7270
environment:

ui/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# If we're in production we want to build the ui and allow nginx to serve the files,
44
# otherwise we run npm install which will create a ui page and use vite to serve it
55
# in "development" mode
6-
if [ $BRAINLIFE_USE_NGINX == true ]; then
6+
if [ "${BRAINLIFE_USE_NGINX:-false}" = "true" ]; then
77
npm run build
88
else
99
npm run dev

0 commit comments

Comments
 (0)