Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
2810d66
#VB-236 - add conditional backend build option in Dockerfile and upda…
jrmartin Apr 1, 2026
8693391
chore: remove default value for BUILD_BACKEND in Dockerfile
jrmartin Apr 2, 2026
2f45e3d
#VFB-236 - add conditional backend launch option in Docker entrypoint…
jrmartin Apr 2, 2026
8187c6f
Update applications/virtual-fly-brain/frontend/vite.config.js
jrmartin Apr 2, 2026
954e85d
feat: add conditional cron service start in Docker entrypoint script
jrmartin Apr 2, 2026
78039f0
Merge branch 'feature/VFB-236' of github.com:MetaCell/virtual-fly-bra…
jrmartin Apr 2, 2026
7367bfa
Merge remote-tracking branch 'origin/development' into feature/VFB-236
jrmartin Apr 3, 2026
b347a29
#VFB-236 : implement conditional cron job setup in Dockerfile based o…
jrmartin Apr 3, 2026
5b34926
#VFB-236 implement conditional backend launch in Docker entrypoint sc…
jrmartin Apr 3, 2026
e146bf2
chore: remove default value for BUILD_BACKEND in Dockerfile to enhanc…
jrmartin Apr 3, 2026
fb3665d
chore: update Dockerfile to set up cache cleanup cron job and streaml…
jrmartin Apr 3, 2026
c3947af
chore: add exec command to start main application in Docker entrypoin…
jrmartin Apr 3, 2026
4b114af
#VFB-236 - Refactor Docker entrypoint script for conditional backend …
jrmartin Apr 3, 2026
7f641ad
#VFB-236 add BUILD_BACKEND environment variable to deployment configu…
jrmartin Apr 3, 2026
30c97ca
#VFRB-236 - enhance Docker entrypoint script for conditional backend …
jrmartin Apr 3, 2026
7d7f2b8
#VFB-236 - enhance Dockerfile and entrypoint script for BUILD_BACKEND…
jrmartin Apr 3, 2026
487b77d
#VFB-236 - add exec command to start main application after condition…
jrmartin Apr 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions applications/virtual-fly-brain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ${CLOUDHARNESS_FLASK}

ARG DOMAIN
ARG BE_DOMAIN
ARG BUILD_BACKEND
Comment thread
jrmartin marked this conversation as resolved.
ARG NEUROGLASS_DATA_PROTOCOL
ARG NEUROGLASS_DATA_BASE_URL
ARG NEUROGLASS_URL
Comment thread
jrmartin marked this conversation as resolved.
Expand All @@ -12,6 +13,7 @@ ENV MODULE_NAME=virtual_fly_brain
ENV WORKERS=2
ENV PORT=8080
ENV BUILDDIR=/app
ENV BUILD_BACKEND=$BUILD_BACKEND

# Update ImageMagick to fix critical security vulnerabilities
# CVE-2025-57807, CVE-2025-55298, CVE-2025-55154, CVE-2025-55212, CVE-2025-57803
Expand Down Expand Up @@ -44,7 +46,7 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
node --version

RUN npm install -g yarn && \
RUN npm install -g yarn serve && \
yarn --version

# Set up virtual display for OpenGL
Expand All @@ -71,9 +73,19 @@ RUN export VFB_DOMAIN="https://${BE_DOMAIN}" && \

WORKDIR /usr/src/app
COPY backend/requirements.txt /usr/src/app/
RUN pip3 install --no-cache-dir -r requirements.txt
# === CONDITIONAL BACKEND BUILD: only if BUILD_BACKEND != "false" ===
RUN if [ "$BUILD_BACKEND" != "false" ]; then \
pip3 install --no-cache-dir -r requirements.txt; \
else \
echo "Skipping backend requirements install."; \
Comment thread
jrmartin marked this conversation as resolved.
fi

COPY backend/ /usr/src/app
RUN pip3 install -e .
RUN if [ "$BUILD_BACKEND" != "false" ]; then \
pip3 install -e .; \
else \
echo "Skipping backend build."; \
fi
Comment thread
jrmartin marked this conversation as resolved.

RUN cp -r ${BUILDDIR}/dist/ /usr/src/app/virtual_fly_brain/www

Expand All @@ -85,12 +97,15 @@ RUN chmod +x /usr/local/bin/vfb_cache_cleanup.sh
COPY backend/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

# Create cron job to run cache cleanup daily at 2 AM
RUN echo "0 2 * * * /usr/local/bin/vfb_cache_cleanup.sh" | crontab -

# Create log directory for cache cleanup logs
RUN mkdir -p /var/log && touch /var/log/vfb_cache_cleanup.log
# Only set up cache cleanup cron if BUILD_BACKEND != "false"
RUN if [ "$BUILD_BACKEND" != "false" ]; then \
echo "0 2 * * * /usr/local/bin/vfb_cache_cleanup.sh" | crontab - && \
mkdir -p /var/log && touch /var/log/vfb_cache_cleanup.log ; \
else \
echo "Skipping cronjob setup for frontend-only builds"; \
fi

WORKDIR /usr/src/app/virtual_fly_brain

EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh", "gunicorn", "--log-level=info", "--preload", "--bind=0.0.0.0:8080", "--timeout=240", "--graceful-timeout=30", "--keep-alive=5", "virtual_fly_brain.__main__:app"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Comment thread
jrmartin marked this conversation as resolved.
19 changes: 16 additions & 3 deletions applications/virtual-fly-brain/backend/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
#!/bin/bash
set -e

# Start cron service in the background
service cron start
echo "BUILD_BACKEND=$BUILD_BACKEND"
env | sort | grep BUILD

# Start cron service in the background (only if backend is enabled)
if [ "$BUILD_BACKEND" != "false" ]; then
service cron start
fi
Comment thread
jrmartin marked this conversation as resolved.

# Create cache directories with proper permissions
mkdir -p /tmp/vfb_cache/term_info /tmp/vfb_cache/queries
chmod 755 /tmp/vfb_cache /tmp/vfb_cache/term_info /tmp/vfb_cache/queries

# Conditional launch: if backend is disabled, serve frontend only
if [ "$BUILD_BACKEND" == "true" ]; then
exec gunicorn --log-level=info --preload --bind=0.0.0.0:8080 --timeout=240 --graceful-timeout=30 --keep-alive=5 virtual_fly_brain.__main__:app
else
exec serve /usr/src/app/virtual_fly_brain/www --single --listen 8080
fi

# Start the main application
exec "$@"
exec "$@"
6 changes: 5 additions & 1 deletion applications/virtual-fly-brain/frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export default defineConfig(({ mode }) => {
// Use VFB_DOMAIN if available (production), otherwise fallback to dev URL
// Check both loadEnv result and direct process.env for Docker builds
// eslint-disable-next-line no-undef
const apiUrl = env.VFB_DOMAIN || process.env.VFB_DOMAIN || 'https://vfb.dev.metacell.us';
const apiUrl = env.VFB_DOMAIN || process.env.VFB_DOMAIN || 'https://v3-cached.virtualflybrain.org';
Comment thread
jrmartin marked this conversation as resolved.

console.log('=== Vite Build Configuration ===');
console.log('Mode:', mode);
console.log('VFB_DOMAIN from loadEnv:', env.VFB_DOMAIN);
Comment thread
jrmartin marked this conversation as resolved.
// eslint-disable-next-line no-undef
const neuroglassProtocol = env.NEUROGLASS_DATA_PROTOCOL || process.env.NEUROGLASS_DATA_PROTOCOL || 'neuroglancer-precomputed';
// eslint-disable-next-line no-undef
Expand Down
1 change: 1 addition & 0 deletions deployment/codefresh-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ steps:
- TAG=${{CF_BUILD_ID}}
- DOMAIN=${{DOMAIN}}
- BE_DOMAIN=${{BE_DOMAIN}}
- BUILD_BACKEND=${{BUILD_BACKEND}}
- NEUROGLASS_DATA_PROTOCOL=${{NEUROGLASS_DATA_PROTOCOL}}
- NEUROGLASS_DATA_BASE_URL=${{NEUROGLASS_DATA_BASE_URL}}
- NEUROGLASS_URL=${{NEUROGLASS_URL}}
Expand Down
Loading