Skip to content

Commit

Permalink
fix: --opbeans-node-agent-local-repo=/a/local/dir (elastic#1084)
Browse files Browse the repository at this point in the history
Fixes './scripts/compose.py start --opbeans-node-agent-local-repo=$dir'
to (a) install the Node.js APM agent into the opbeans-node app at "/app"
and (b) to skip copying the possibly large node_modules and build dirs
for speed.

Fixes: elastic#1083

# Conflicts:
#	README.md
  • Loading branch information
trentm committed Apr 28, 2021
1 parent e2afa90 commit 7281c0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions docker/opbeans/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ARG OPBEANS_NODE_IMAGE=opbeans/opbeans-node
ARG OPBEANS_NODE_VERSION=latest
FROM ${OPBEANS_NODE_IMAGE}:${OPBEANS_NODE_VERSION}

RUN apk --no-cache add rsync
COPY entrypoint.sh /app/entrypoint.sh

CMD ["pm2-runtime", "ecosystem-workload.config.js"]
Expand Down
12 changes: 7 additions & 5 deletions docker/opbeans/node/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env sh
set -ex
if [ -f /local-install/package.json ]; then
echo "Installing from local folder"
# copy to folder inside container to ensure were not poluting the local folder
cp -r /local-install ~
cd ~/local-install && npm install .
cd -
echo "Installing elastic-apm-node from local folder (--opbeans-node-agent-local-repo)"
# Copy to a folder inside container to ensure we're not polluting the
# local folder. Skip possibly huge dirs to speed this up.
rsync -a /local-install/ ~/local-install/ --exclude node_modules --exclude build --exclude .git
# Install elastic-apm-node from this copied dir.
npm install ~/local-install
npm ls elastic-apm-node
elif [ -n "${NODE_AGENT_VERSION}" ]; then
echo "Installing ${NODE_AGENT_VERSION} from npm"
npm install elastic-apm-node@"${NODE_AGENT_VERSION}"
Expand Down

0 comments on commit 7281c0f

Please sign in to comment.