Skip to content

Commit

Permalink
Added deploy scripts for remaining apps
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisassad committed Sep 26, 2024
1 parent 9c54302 commit 845fad3
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 65 deletions.
7 changes: 4 additions & 3 deletions Dockerfile.commonwealth_base
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-slim AS base
FROM datadog-base AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
Expand Down Expand Up @@ -27,18 +27,19 @@ FROM base AS commonwealth
ENV NODE_ENV=production
COPY --from=build /prod/commonwealth /prod/commonwealth
WORKDIR /prod/commonwealth
RUN apt-get update && apt-get install -y curl # Needed for heroku
COPY ./scripts/datadog-entrypoint.sh /prod/commonwealth
ENV PORT=$PORT

FROM base AS snapshot-listener
ENV NODE_ENV=production
COPY --from=build /prod/snapshot-listener /prod/snapshot-listener
WORKDIR /prod/snapshot-listener
COPY ./scripts/datadog-entrypoint.sh /prod/snapshot-listener
ENV PORT=$PORT

FROM base AS discord-bot
ENV NODE_ENV=production
COPY --from=build /prod/discord-bot /prod/discord-bot
WORKDIR /prod/discord-bot
RUN apt-get update && apt-get install -y curl # Needed for heroku
COPY ./scripts/datadog-entrypoint.sh /prod/discord-bot
ENV PORT=$PORT
26 changes: 26 additions & 0 deletions Dockerfile.datadog
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:20-slim AS datadog-base

# Install Datadog dependencies
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 Datadog Agent
RUN apt-get update && apt-get -y install --reinstall datadog-agent

# Expose DogStatsD and trace-agent ports
EXPOSE 8125/udp 8126/tcp
4 changes: 2 additions & 2 deletions packages/commonwealth/deploy/dockerfiles/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
FROM commonwealth
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register build/server/workers/commonwealthConsumer/commonwealthConsumer.js
4 changes: 2 additions & 2 deletions packages/commonwealth/deploy/dockerfiles/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
FROM commonwealth
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register build/server/workers/evmChainEvents/startEvmPolling.js
4 changes: 2 additions & 2 deletions packages/commonwealth/deploy/dockerfiles/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
FROM commonwealth
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register build/server/workers/knock/knockWorker.js
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
FROM commonwealth
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register build/server/workers/messageRelayer/messageRelayer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM commonwealth_base
FROM commonwealth
RUN apt-get update && apt-get install -y curl # Needed for heroku
CMD node --import=extensionless/register build/server/scripts/releasePhaseEnvCheck.js && \
npx sequelize-cli db:migrate --config server/sequelize.json && \
Expand Down
39 changes: 2 additions & 37 deletions packages/commonwealth/deploy/dockerfiles/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"]
FROM commonwealth
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register --enable-source-maps" ./build/server.js
2 changes: 2 additions & 0 deletions packages/discord-bot/deploy/dockerfiles/Dockerfile.consumer
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM discord-bot
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register ./build/discord-consumer/discordConsumer.js
2 changes: 2 additions & 0 deletions packages/discord-bot/deploy/dockerfiles/Dockerfile.listener
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM discord-bot
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register ./build/discord-listener/discordListener.js
3 changes: 3 additions & 0 deletions packages/discord-bot/deploy/dockerfiles/Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM discord-bot
RUN apt-get update && apt-get install -y curl
CMD node --import=extensionless/register ./build/scripts/releasePhaseEnvCheck.js
2 changes: 0 additions & 2 deletions packages/snapshot-listener/Procfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM snapshot-listener
RUN apt-get update && apt-get install
CMD ./datadog-entrypoint.sh NODE_ENV=production node --import=extensionless/register ./build/scripts/releasePhaseEnvCheck.js
2 changes: 2 additions & 0 deletions packages/snapshot-listener/deploy/dockerfiles/Dockerfile.web
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM snapshot-listener
CMD ./datadog-entrypoint.sh NODE_ENV=production --import=extensionless/register --enable-source-maps ./build/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@
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

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

exec "$@"
46 changes: 33 additions & 13 deletions scripts/deploy-to-heroku.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,44 @@ fi

cp ${env_path} .env

docker build . --target commonwealth -f Dockerfile.commonwealth_base -t commonwealth_base
# Needed for commonwealth_base
docker build -f Dockerfile.datadog -t datadog-base .

commonwealth_path=./packages/commonwealth/deploy/dockerfiles
deploy_heroku_app() {
local app_path=$1
local app_name=$2

process_types=""
for dockerfile in ${commonwealth_path}/Dockerfile.*; do
base_name=$(basename $dockerfile | cut -d. -f2)
process_types=""
for dockerfile in ${app_path}/Dockerfile.*; do
base_name=$(basename $dockerfile | cut -d. -f2)

heroku_tag=registry.heroku.com/${app_name}/${base_name}
heroku_tag=registry.heroku.com/${app_name}/${base_name}

docker build -f ${dockerfile} -t ${heroku_tag}:latest .
docker build -f ${dockerfile} -t ${heroku_tag}:latest .

echo docker image ls
echo docker image ls

docker push ${heroku_tag}:latest
docker push ${heroku_tag}:latest

process_types="${process_types} ${base_name}"
done
process_types="${process_types} ${base_name}"
done

process_types=$(echo $process_types | xargs)
heroku container:release ${process_types} -a ${app_name}
process_types=$(echo $process_types | xargs)
heroku container:release ${process_types} -a ${app_name}
}

docker build . --target commonwealth -t commonewalth -f Dockerfile.commonwealth_base
deploy_heroku_app "./packages/commonwealth/deploy/dockerfiles" ${app_name}

snapshot_listener_app_name=snapshot-listener-staging
discord_bot_app_name=discobot-listener-staging
if [ "${app_name}" == "commonwealthapp" ]; then
snapshot_listener_app_name="snapshot-listener"
discord_bot_app_name="discobot-listener"
fi

docker build . --target snapshot-listener -t snapshot-listener -f Dockerfile.commonwealth_base
deploy_heroku_app "./packages/snapshot-listener/deploy/dockerfiles" ${snapshot_listner_app_name}

docker build . --target discord_bot -t discord-bot -f Dockerfile.commonwealth_base
deploy_heroku_app "./packages/discord-bot/deploy/dockerfiles" ${discord_bot_app_name}

0 comments on commit 845fad3

Please sign in to comment.