diff --git a/Dockerfile.commonwealth_base b/Dockerfile.commonwealth_base index f05519c36f6..cfc5739588b 100644 --- a/Dockerfile.commonwealth_base +++ b/Dockerfile.commonwealth_base @@ -2,6 +2,31 @@ FROM node:20-slim AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable +RUN apt-get update \ + && apt-get install -y gnupg apt-transport-https gpg-agent curl ca-certificates + +ENV DATADOG_APT_KEYRING="/usr/share/keyrings/datadog-archive-keyring.gpg" +ENV DATADOG_APT_KEYS_URL="https://keys.datadoghq.com" +RUN sh -c "echo 'deb [signed-by=${DATADOG_APT_KEYRING}] https://apt.datadoghq.com/ stable 7' > /etc/apt/sources.list.d/datadog.list" +RUN touch ${DATADOG_APT_KEYRING} +RUN curl -o /tmp/DATADOG_APT_KEY_CURRENT.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_CURRENT.public" && \ + gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_CURRENT.public +RUN curl -o /tmp/DATADOG_APT_KEY_06462314.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_06462314.public" && \ + gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_06462314.public +RUN curl -o /tmp/DATADOG_APT_KEY_C0962C7D.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_C0962C7D.public" && \ + gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_C0962C7D.public +RUN curl -o /tmp/DATADOG_APT_KEY_F14F620E.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_F14F620E.public" && \ + gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_F14F620E.public +RUN curl -o /tmp/DATADOG_APT_KEY_382E94DE.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_382E94DE.public" && \ + gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_382E94DE.public + +RUN apt-get update && apt-get -y --force-yes install --reinstall datadog-agent + +RUN chmod +x /prod/commonwealth/datadog-entrypoint.sh + +COPY datadog-config/ /etc/datadog-agent/ + +EXPOSE 8125/udp 8126/tcp FROM base AS build ## needed for node-gyp to build @@ -20,3 +45,4 @@ COPY --from=build /prod/commonwealth /prod/commonwealth WORKDIR /prod/commonwealth RUN apt-get update && apt-get install -y curl # Needed for heroku ENV PORT=$PORT +COPY ./scripts/datadog-entrypoint.sh /prod/commonwealth diff --git a/Dockerfile.consumer b/Dockerfile.consumer index 5619fad9fd7..f52ffa3aea9 100644 --- a/Dockerfile.consumer +++ b/Dockerfile.consumer @@ -1,2 +1,2 @@ FROM commonwealth_base -CMD node --import=extensionless/register build/server/workers/commonwealthConsumer/commonwealthConsumer.js \ No newline at end of file +CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/commonwealthConsumer/commonwealthConsumer.js \ No newline at end of file diff --git a/Dockerfile.evm_ce b/Dockerfile.evm_ce index 32d90b4f9e0..cd2e100ec84 100644 --- a/Dockerfile.evm_ce +++ b/Dockerfile.evm_ce @@ -1,2 +1,2 @@ FROM commonwealth_base -CMD node --import=extensionless/register build/server/workers/evmChainEvents/startEvmPolling.js \ No newline at end of file +CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/evmChainEvents/startEvmPolling.js \ No newline at end of file diff --git a/Dockerfile.knock b/Dockerfile.knock index 91bd24c601a..54ea6a8287b 100644 --- a/Dockerfile.knock +++ b/Dockerfile.knock @@ -1,2 +1,2 @@ FROM commonwealth_base -CMD node --import=extensionless/register build/server/workers/knock/knockWorker.js \ No newline at end of file +CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/knock/knockWorker.js \ No newline at end of file diff --git a/Dockerfile.message_relayer b/Dockerfile.message_relayer index 87b9d2d9fac..9143802ff80 100644 --- a/Dockerfile.message_relayer +++ b/Dockerfile.message_relayer @@ -1,2 +1,2 @@ FROM commonwealth_base -CMD node --import=extensionless/register build/server/workers/messageRelayer/messageRelayer.js \ No newline at end of file +CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/messageRelayer/messageRelayer.js \ No newline at end of file diff --git a/Dockerfile.web b/Dockerfile.web index e242d4587c4..79c137a3a68 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -1,37 +1,2 @@ FROM commonwealth_base - -RUN apt-get update \ - && apt-get install -y gnupg apt-transport-https gpg-agent curl ca-certificates - -# Add Datadog repository and signing keys -ENV DATADOG_APT_KEYRING="/usr/share/keyrings/datadog-archive-keyring.gpg" -ENV DATADOG_APT_KEYS_URL="https://keys.datadoghq.com" -RUN sh -c "echo 'deb [signed-by=${DATADOG_APT_KEYRING}] https://apt.datadoghq.com/ stable 7' > /etc/apt/sources.list.d/datadog.list" -RUN touch ${DATADOG_APT_KEYRING} -RUN curl -o /tmp/DATADOG_APT_KEY_CURRENT.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_CURRENT.public" && \ - gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_CURRENT.public -RUN curl -o /tmp/DATADOG_APT_KEY_06462314.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_06462314.public" && \ - gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_06462314.public -RUN curl -o /tmp/DATADOG_APT_KEY_C0962C7D.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_C0962C7D.public" && \ - gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_C0962C7D.public -RUN curl -o /tmp/DATADOG_APT_KEY_F14F620E.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_F14F620E.public" && \ - gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_F14F620E.public -RUN curl -o /tmp/DATADOG_APT_KEY_382E94DE.public "${DATADOG_APT_KEYS_URL}/DATADOG_APT_KEY_382E94DE.public" && \ - gpg --ignore-time-conflict --no-default-keyring --keyring ${DATADOG_APT_KEYRING} --import /tmp/DATADOG_APT_KEY_382E94DE.public - - -# Install the Datadog Agent -RUN apt-get update && apt-get -y --force-yes install --reinstall datadog-agent - -# Copy entrypoint -COPY ./scripts/heroku-entrypoint.sh /prod/commonwealth - -RUN chmod +x /prod/commonwealth/heroku-entrypoint.sh - -# Copy your Datadog configuration -COPY datadog-config/ /etc/datadog-agent/ - -# Expose DogStatsD and trace-agent ports -EXPOSE 8125/udp 8126/tcp - -CMD ["./heroku-entrypoint.sh"] \ No newline at end of file +CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register --enable-source-maps ./build/server.js \ No newline at end of file diff --git a/scripts/heroku-entrypoint.sh b/scripts/datadog-entrypoint.sh similarity index 64% rename from scripts/heroku-entrypoint.sh rename to scripts/datadog-entrypoint.sh index d62ae205bfa..2d57ebe4c8a 100644 --- a/scripts/heroku-entrypoint.sh +++ b/scripts/datadog-entrypoint.sh @@ -3,4 +3,10 @@ datadog-agent run & /opt/datadog-agent/embedded/bin/trace-agent --config=/etc/datadog-agent/datadog.yaml & /opt/datadog-agent/embedded/bin/process-agent --config=/etc/datadog-agent/datadog.yaml & -NODE_ENV=production node --import=extensionless/register --enable-source-maps ./build/server.js \ No newline at end of file + +if [ -z "$1" ]; then + echo "Error: No command provided to run. Usage: $0 " + exit 1 +fi + +exec "$@" \ No newline at end of file