Skip to content

Commit ee54561

Browse files
authored
Merge pull request #119 from fractal-analytics-platform/new-example-for-testing
Add `staging-full-stack` example
2 parents db05fa5 + 614d9ea commit ee54561

23 files changed

+514
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
services:
2+
db:
3+
cpus: 1.0
4+
mem_limit: "1G"
5+
container_name: fractal-db
6+
image: postgres:15.4-alpine
7+
restart: always
8+
ports:
9+
- 5433:5433
10+
command: -p 5433
11+
environment:
12+
POSTGRES_USER: fractal
13+
POSTGRES_PASSWORD: fractal
14+
POSTGRES_DB: fractal
15+
# required for the check below - otherwise postgresql
16+
# will use undefined 'root' user and raise errors
17+
PGUSER: fractal
18+
healthcheck:
19+
# postgresql starts up, stops, and then restarts
20+
# => errors if the server connects before the stop
21+
# this checks if the system is ready
22+
test: pg_isready -p 5433
23+
interval: 5s
24+
timeout: 5s
25+
retries: 5
26+
volumes:
27+
- postgres_db:/var/lib/postgresql/data
28+
networks:
29+
- fractal
30+
31+
server:
32+
hostname: server
33+
container_name: server
34+
cpus: 3.0
35+
mem_limit: 5g
36+
build:
37+
context: server
38+
dockerfile: Dockerfile
39+
args:
40+
- FRACTAL_SERVER_VERSION=2.14.0a0
41+
depends_on:
42+
db:
43+
condition: service_healthy
44+
volumes:
45+
- data:/data
46+
ports:
47+
- 8000:8000
48+
healthcheck:
49+
test: wget http://server:8000/api/alive/ > /dev/null 2>&1
50+
interval: 5s
51+
timeout: 2s
52+
retries: 5
53+
networks:
54+
- fractal
55+
56+
web:
57+
container_name: fractal-web
58+
build:
59+
context: ./web
60+
dockerfile: Dockerfile
61+
args:
62+
- FRACTAL_WEB_VERSION=1.17.0-a0
63+
depends_on:
64+
server:
65+
condition: service_healthy
66+
ports:
67+
- 5173:5173
68+
networks:
69+
- fractal
70+
71+
server-config:
72+
container_name: server-config
73+
build:
74+
context: ./server-config
75+
args:
76+
- FRACTAL_CLIENT_VERSION=2.7.1
77+
depends_on:
78+
server:
79+
condition: service_healthy
80+
volumes:
81+
- data:/data
82+
networks:
83+
- fractal
84+
85+
fractal-filebrowser:
86+
container_name: fractal-filebrowser
87+
build:
88+
context: ./filebrowser
89+
ports:
90+
- 8080:80
91+
networks:
92+
- fractal
93+
volumes:
94+
- data:/data
95+
96+
vizarr:
97+
container_name: vizarr
98+
image: ghcr.io/fractal-analytics-platform/fractal-vizarr-viewer:stable
99+
environment:
100+
- FRACTAL_SERVER_URL=http://server:8000
101+
- AUTHORIZATION_SCHEME=fractal-server
102+
ports:
103+
- 3000:3000
104+
networks:
105+
- fractal
106+
volumes:
107+
- data:/data:ro
108+
109+
volumes:
110+
data:
111+
postgres_db:
112+
113+
networks:
114+
fractal:
115+
driver: bridge
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM filebrowser/filebrowser:v2
2+
RUN apk update
3+
RUN apk add inotify-tools openrc
4+
COPY check_file.sh /usr/check_file.sh
5+
COPY monitord /etc/init.d/monitord
6+
RUN chmod +x /usr/check_file.sh
7+
RUN chmod +x /etc/init.d/monitord
8+
COPY conf_files/filebrowser.db database.db
9+
COPY conf_files/filebrowser.json .filebrowser.json
10+
RUN mkdir -p /branding/img/icons
11+
ADD conf_files/favicon-16x16.png branding/img/icons
12+
ADD conf_files/favicon-32x32.png branding/img/icons
13+
ADD conf_files/logo.svg branding/img
14+
RUN /filebrowser config set --auth.method=noauth
15+
RUN /filebrowser config set --branding.name "Fractal FileBrowser" --branding.files "/branding" --branding.disableExternal
16+
RUN /filebrowser users update 1 --perm.admin=false
17+
COPY entrypoint.sh /entrypoint.sh
18+
RUN chmod +x /entrypoint.sh
19+
ENTRYPOINT /entrypoint.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Note: To make the files uploaded/created in the `/data` dir broadly accessible, we added a service called `monitord` into the `fractal-filebrowser` container. This service uses `inotifywait` tool to check when a new file or dir is created within the `/data` folder, and modify its permission from 0644 to 0666.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
DIRECTORY_TO_WATCH="/data"
3+
echo $$ > /run/monitord.pid
4+
# Monitor the directory and change permissions
5+
inotifywait -m -e create --format '%w%f' "$DIRECTORY_TO_WATCH" | while read NEW_FILE; do
6+
chmod -R 0666 "$NEW_FILE"
7+
echo "Changed permissions for $NEW_FILE"
8+
done
Loading
Loading
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"port": 80,
3+
"log": "stdout",
4+
"database": "/database.db",
5+
"root": "/data"
6+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
openrc default # set runlevel to default
4+
rc-update add monitord default # add monitord service to system services
5+
service monitord start
6+
7+
/filebrowser
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/sbin/openrc-run
2+
3+
name="Monitor data dir and change Permissions"
4+
description="Monitor data and change permissions for newly created files"
5+
command="/usr/check_file.sh"
6+
command_background=true
7+
pidfile="/run/monitord.pid"

examples/staging-full-stack/makefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Auxiliary targets
2+
3+
up:
4+
docker compose up
5+
6+
build:
7+
docker compose build --progress=plain
8+
9+
build-no-cache:
10+
docker compose build --no-cache --progress=plain
11+
12+
clean:
13+
docker compose down -v --timeout 1
14+
15+
clean-with-volumes:
16+
docker compose down --volumes -v --timeout 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FRACTAL_USER=[email protected]
2+
FRACTAL_PASSWORD=1234
3+
FRACTAL_SERVER=http://localhost:8000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
venv
2+
.cache
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Set cache path to the local directory, remove it if it exists
4+
FRACTAL_CACHE_PATH=$(pwd)/".cache"
5+
export FRACTAL_CACHE_PATH="$FRACTAL_CACHE_PATH"
6+
if [ -d "$FRACTAL_CACHE_PATH" ]; then
7+
rm -rv "$FRACTAL_CACHE_PATH" 2> /dev/null
8+
fi
9+
10+
fractal task collect fractal-tasks-core --package-extras fractal-tasks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Exit immediately if a command exits with a non-zero status
4+
set -e
5+
6+
LABEL="cardiac"
7+
8+
PROJECT_NAME="proj-$LABEL"
9+
DS_NAME="ds-$LABEL"
10+
WF_NAME="Workflow $LABEL"
11+
ZARR_DIR=/data/zarrs/${LABEL}
12+
13+
14+
# Set cache path to the local directory, remove it if it exists
15+
FRACTAL_CACHE_PATH=$(pwd)/".cache"
16+
export FRACTAL_CACHE_PATH="$FRACTAL_CACHE_PATH"
17+
if [ -d "$FRACTAL_CACHE_PATH" ]; then
18+
rm -rv "$FRACTAL_CACHE_PATH" 2> /dev/null
19+
fi
20+
21+
22+
# Create project
23+
PROJECT_ID=$(fractal --batch project new "$PROJECT_NAME")
24+
echo "PROJECT_ID=$PROJECT_ID created"
25+
26+
# Add input dataset, and add a resource to it
27+
DS_ID=$(fractal --batch project add-dataset "$PROJECT_ID" "$DS_NAME" --zarr-dir "$ZARR_DIR")
28+
echo "DS_IN_ID=$DS_ID created"
29+
30+
# Import workflow
31+
WF_ID=$(fractal --batch workflow import --project-id "$PROJECT_ID" --json-file workflow.json --workflow-name "$WF_NAME")
32+
echo "WF_ID=$WF_ID created"

0 commit comments

Comments
 (0)