Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ gradle.properties
.vscode/settings.json
public-api/.docker-sync/daemon.log
public-ui/.angular/cache/*
public-ui/npmrc
public-ui/npmrc
aou-utils/
5 changes: 5 additions & 0 deletions public-api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion public-api/db-cdr/generate-cdr/init-new-cdr-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,4 +98,4 @@ then
fi

# Success
exit 0
exit 0
15 changes: 15 additions & 0 deletions public-api/libproject/devstart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion public-api/src/dev/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ RUN unzip gradle.zip && rm gradle.zip \
ENV PATH="$PATH:/gradle/bin"
WORKDIR /

COPY with-uid.sh /usr/local/bin
# 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
7 changes: 4 additions & 3 deletions public-api/src/dev/server/with-uid.sh
Original file line number Diff line number Diff line change
@@ -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 $@
exec "$@"