Skip to content

Conversation

@bendhouseart
Copy link
Collaborator

  • Added .gitignore and README
  • Updated README for formatting
  • Adding apptainer scripts

bendhouseart and others added 30 commits September 11, 2024 11:36
* added setup script, removed password for ssl certs
* updated handler and setup.sh
* added acquisition date and time fields to intermediate sidecar files 
and scrub those same dates from BIDS Finalized output sidecars
* added instructions in launch.sh
* Added .gitignore and README
* Updated README for formatting
* Adding apptainer scripts

---------

Co-authored-by: Marc Cummings <[email protected]>
@bendhouseart bendhouseart self-assigned this Feb 6, 2025
@bendhouseart
Copy link
Collaborator Author

@kiwimarc Okay, maybe this is because I'm being difficult and running singularity/apptainer on Debian, but I'm unable to load the environment variables stored in my .env file via source. As a result the handler fails to start since the variable it's evaluating does not exist:

INFO:    instance started successfully
Waiting for Handler to be ready...
Starting UI container...
INFO:    Instance stats will not be available - requires cgroups v2 with systemd as manager.
/entrypoint.sh: line 6: [: ==: unary operator expected

INFO:    instance started successfully

@kiwimarc
Copy link

kiwimarc commented Feb 6, 2025

The problem is that Apptainer containers dont adopt the host environment variables
So this in entrypoint.sh at line 6, will not work:
if [ $BRAINLIFE_PRODUCTION == true ]; then

Because in run_apptainer.sh, it is missing something like:
--env "BRAINLIFE_PRODUCTION=$BRAINLIFE_PRODUCTION"

I can try to push an update and then you can test if it works :D

EDIT: I was wrong, maybe:

If you have environment variables set outside of your container, on the host, then by default they will be available inside the container. Except that:
An environment variable set on the host will be overridden by a variable of the same name that has been set either inside the container image, or via APPTAINERENV_ environment variables, or the --env and --env-file flags.
The PS1 shell prompt is reset for a container specific prompt.
The PATH environment variable will be modified to contain default values.
The LD_LIBRARY_PATH is modified to a default /.singularity.d/libs, that will include NVIDIA / ROCm libraries if applicable.

https://apptainer.org/docs/user/main/environment_and_metadata.html#environment-from-the-host

@kiwimarc
Copy link

kiwimarc commented Feb 6, 2025

@bendhouseart
Can you try to run this:

host> apptainer instance run --env "VITE_APIHOST=http://localhost:8082"  ui.sif ui ./start_ui.sh
host> apptainer shell instance://ui
Apptainer> echo $BRAINLIFE_PRODUCTION 

Just be sure that its the $BRAINLIFE_PRODUCTION variable that is missing

@bendhouseart
Copy link
Collaborator Author

Sorry, it's source that isn't behaving. When the environment variables are present on the host they are loaded into the container. This is very much a me problem with my Debian dev machine.

anthony@ip-10-0-1-167:~/ezbids$ cat .env
# Create/Copy this file as .env in the root of the project to set default environment variables

# insert your host name here, it should match your ssl certificate and/or the output
# of echo $HOSTNAME
SERVER_NAME=localhost

# Set the BRAINLIFE_PRODUCTION environment variable to true to use https"
# (this will launch the services on port 443) and run with nginx/production_nginx.conf"
# this will require providing the correct paths for the SSL_CERT_PATH, SSL_KEY_PATH and SSL_PASSWORD_PATH
# with false the UI will run on 3000"
BRAINLIFE_PRODUCTION=false

SSL_CERT_PATH=./nginx/ssl/sslcert.cert
SSL_KEY_PATH=./nginx/ssl/sslcert.key
SSL_PASSWORD_PATH=./nginx/ssl/sslpassword #if your key is not encrypted use an arbitrary path here

# Set the BRAINLIFE_AUTHENTICATION environment variable to true, if you're not running"
# this with brainlife don't use."
BRAINLIFE_AUTHENTICATION=false

# Set the BRAINLIFE_DEVELOPMENT enables additional debugging output and mounts 
# the ezbids repo/folder into the various containers default is false"
BRAINLIFE_DEVELOPMENT=false

# Define which profiles to use, e.g. set to COMPOSE_PROFILES=telemetry to enable telemetry 
COMPOSE_PROFILES=anthony@ip-10-0-1-167:~/ezbids$ source .env 
anthony@ip-10-0-1-167:~/ezbids$ env | grep BRAINLIFE
anthony@ip-10-0-1-167:~/ezbids$ 

I mentioned it earlier so that I'd be able to keep track of what was going on.

* added setup script, removed password requirment for ssl certs
* updated handler and setup.sh
* added acquisiiton date and time fields
* scrub dates from BIDS Finalized output
* added instructions in launch.sh
* fix compose that got bungled during merge.
* Update handler/Dockerfile
@melanieganz
Copy link
Collaborator

Hi @bendhouseart,
so right now Docker support is dead and we need the apptainer to work. The original apptainer by Marc worked here at NRU before you merged a lot of other stuff in. Can we revert to that stage and test here what is going on? What was all added beyond what Marc did in the apptainer branch?

@bendhouseart bendhouseart deleted the apptainer branch March 4, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants