diff --git a/.gitignore b/.gitignore index c9c3c2674..5f453733a 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ gradle.properties .vscode/settings.json public-api/.docker-sync/daemon.log public-ui/.angular/cache/* -public-ui/npmrc \ No newline at end of file +public-ui/npmrc +aou-utils/ \ No newline at end of file diff --git a/public-api/.gitignore b/public-api/.gitignore index a530464af..0a91eeaae 100644 --- a/public-api/.gitignore +++ b/public-api/.gitignore @@ -19,3 +19,8 @@ hs_err_pid* target .gradle build +docker-compose.yaml +db-cdr/generate-cdr/init-new-cdr-db.sh +libproject/devstart.rb +src/dev/server/Dockerfile +src/dev/server/with-uid.sh diff --git a/public-api/db-cdr/generate-cdr/init-new-cdr-db.sh b/public-api/db-cdr/generate-cdr/init-new-cdr-db.sh index 4a6d0ba6c..ce27bfc77 100755 --- a/public-api/db-cdr/generate-cdr/init-new-cdr-db.sh +++ b/public-api/db-cdr/generate-cdr/init-new-cdr-db.sh @@ -28,6 +28,13 @@ then exit 1 fi +# Activate service account if credentials are available +if [ -n "$GOOGLE_APPLICATION_CREDENTIALS" ] && [ -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then + echo "Activating service account: $GOOGLE_APPLICATION_CREDENTIALS" + gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS" +else + echo "Warning: No service account credentials found at $GOOGLE_APPLICATION_CREDENTIALS" +fi # export for liquibase to use this export CDR_DB_NAME @@ -91,4 +98,4 @@ then fi # Success -exit 0 +exit 0 \ No newline at end of file diff --git a/public-api/libproject/devstart.rb b/public-api/libproject/devstart.rb index 4fd501bb9..955d2c609 100644 --- a/public-api/libproject/devstart.rb +++ b/public-api/libproject/devstart.rb @@ -113,6 +113,21 @@ def dev_up() raise("Please run 'gcloud auth login' before starting the server.") end + begin + docker_version = common.capture_stdout(%W{docker -v}).strip + compose_version = common.capture_stdout(%W{docker-compose -v}).strip + + common.status "Docker version: #{docker_version}" + common.status "Docker Compose version: #{compose_version}" + rescue => e + common.status "Warning: Could not detect Docker versions - #{e.message}" + end + + at_exit { common.run_inline %W{docker-compose down} } + + ServiceAccountContext.new(TEST_PROJECT).run do + end + at_exit { common.run_inline %W{docker-compose down} } ServiceAccountContext.new(TEST_PROJECT).run do diff --git a/public-api/src/dev/server/Dockerfile b/public-api/src/dev/server/Dockerfile index 066fdf006..fac7454a8 100644 --- a/public-api/src/dev/server/Dockerfile +++ b/public-api/src/dev/server/Dockerfile @@ -74,4 +74,8 @@ RUN unzip gradle.zip && rm gradle.zip \ ENV PATH="$PATH:/gradle/bin" WORKDIR / -COPY with-uid.sh /usr/local/bin \ No newline at end of file +# Create .dockerenv file so scripts can detect they're running inside Docker +RUN touch /.dockerenv + +COPY with-uid.sh /usr/local/bin +RUN chmod +x /usr/local/bin/with-uid.sh \ No newline at end of file diff --git a/public-api/src/dev/server/with-uid.sh b/public-api/src/dev/server/with-uid.sh index 202878446..d56f3ccdd 100755 --- a/public-api/src/dev/server/with-uid.sh +++ b/public-api/src/dev/server/with-uid.sh @@ -1,12 +1,13 @@ -#!/bin/sh +#!/bin/bash USERNAME=$(whoami 2>/dev/null) EXIT_CODE=$? -if [[ $EXIT_CODE -eq 0 ]]; then +# Allow 'core' user for development +if [ $EXIT_CODE -eq 0 ] && [ "$USERNAME" != "core" ]; then >&2 echo 'This container has poor behavior if run as an existing user.' \ 'The given UID matches the user '"'$USERNAME'"'. Exiting.'; exit 1; fi -exec $@ \ No newline at end of file +exec "$@" \ No newline at end of file