Skip to content

Commit

Permalink
abstracted out datadog
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisassad committed Oct 1, 2024
1 parent 7451535 commit fa8cddc
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 41 deletions.
26 changes: 26 additions & 0 deletions Dockerfile.commonwealth_base
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion Dockerfile.consumer
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM commonwealth_base
CMD node --import=extensionless/register build/server/workers/commonwealthConsumer/commonwealthConsumer.js
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/commonwealthConsumer/commonwealthConsumer.js
2 changes: 1 addition & 1 deletion Dockerfile.evm_ce
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM commonwealth_base
CMD node --import=extensionless/register build/server/workers/evmChainEvents/startEvmPolling.js
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/evmChainEvents/startEvmPolling.js
2 changes: 1 addition & 1 deletion Dockerfile.knock
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM commonwealth_base
CMD node --import=extensionless/register build/server/workers/knock/knockWorker.js
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/knock/knockWorker.js
2 changes: 1 addition & 1 deletion Dockerfile.message_relayer
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM commonwealth_base
CMD node --import=extensionless/register build/server/workers/messageRelayer/messageRelayer.js
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register build/server/workers/messageRelayer/messageRelayer.js
37 changes: 1 addition & 36 deletions Dockerfile.web
Original file line number Diff line number Diff line change
@@ -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"]
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register --enable-source-maps ./build/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

if [ -z "$1" ]; then
echo "Error: No command provided to run. Usage: $0 <your_command>"
exit 1
fi

exec "$@"

0 comments on commit fa8cddc

Please sign in to comment.