-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d73237
commit 79d12ea
Showing
40 changed files
with
454 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ node_modules/ | |
**/test-results | ||
**/*.tsbuildinfo | ||
**/.DS_Store | ||
*.env | ||
*.log | ||
.idea | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
- frick | ||
- frack | ||
- production | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set Heroku app name based on branch | ||
id: set-heroku-app-name | ||
run: | | ||
BRANCH_NAME=${GITHUB_REF##*/} | ||
case $BRANCH_NAME in | ||
frick) | ||
APP_NAME="commonwealth-frick" | ||
;; | ||
frack) | ||
APP_NAME="commonwealth-frack" | ||
;; | ||
staging) | ||
APP_NAME="commonwealth-beta" | ||
;; | ||
demo) | ||
APP_NAME="commonwealth-demo" | ||
;; | ||
production) | ||
APP_NAME="commonwealthapp" | ||
;; | ||
*) | ||
echo "Branch $BRANCH_NAME is not configured for deployment." | ||
exit 1 | ||
;; | ||
esac | ||
echo "HEROKU_APP_NAME=$APP_NAME" >> $GITHUB_ENV | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Deploy to Heroku | ||
run: | | ||
chmod +x ./scripts/deploy-to-heroku.sh | ||
./scripts/deploy-to-heroku.sh "${{ secrets.HEROKU_EMAIL }}" "${{ secrets.HEROKU_API_TOKEN }}" "${{ env.HEROKU_APP_NAME }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
FROM datadog-base AS base | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
FROM base AS build | ||
## needed for node-gyp to build | ||
RUN apt-get update && \ | ||
apt-get install -y python3 make gcc g++ | ||
COPY . /usr/src/app | ||
WORKDIR /usr/src/app | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | ||
RUN pnpm run build | ||
|
||
RUN pnpm -F discord-bot run build | ||
RUN pnpm deploy -F discord-bot --prod /prod/discord-bot | ||
RUN mv /usr/src/app/packages/discord-bot/build /prod/discord-bot/build | ||
|
||
RUN pnpm -F snapshot-listener run build | ||
RUN pnpm deploy -F snapshot-listener --prod /prod/snapshot-listener | ||
RUN mv /usr/src/app/packages/snapshot-listener/build /prod/snapshot-listener/build | ||
|
||
RUN pnpm deploy -F commonwealth --prod /prod/commonwealth | ||
RUN mv /usr/src/app/packages/commonwealth/build /prod/commonwealth/build | ||
|
||
FROM base AS commonwealth | ||
ENV NODE_ENV=production | ||
COPY --from=build /prod/commonwealth /prod/commonwealth | ||
WORKDIR /prod/commonwealth | ||
COPY ./scripts/datadog-entrypoint.sh /prod/commonwealth | ||
RUN chmod +x /prod/commonwealth/datadog-entrypoint.sh | ||
COPY ./scripts/get-max-old-space-size.sh /prod/commonwealth/scripts | ||
RUN chmod +x /prod/commonwealth/scripts/get-max-old-space-size.sh | ||
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 | ||
RUN chmod +x /prod/snapshot-listener/datadog-entrypoint.sh | ||
COPY ./scripts/get-max-old-space-size.sh /prod/snapshot-listener/scripts | ||
RUN chmod +x /prod/snapshot-listener/scripts/get-max-old-space-size.sh | ||
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 | ||
COPY ./scripts/datadog-entrypoint.sh /prod/discord-bot | ||
RUN chmod +x /prod/discord-bot/datadog-entrypoint.sh | ||
COPY ./scripts/get-max-old-space-size.sh /prod/discord-bot/scripts | ||
RUN chmod +x /prod/discord-bot/scripts/get-max-old-space-size.sh | ||
ENV PORT=$PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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 | ||
|
||
COPY datadog-config/ /etc/datadog-agent/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Deployment Flow | ||
In order to perform a deployment, we need to push to a branch that corresponds with a heroku application. The branches | ||
are frick, frack, beta. This then runs a github action that takes care of the deployment. | ||
|
||
# Deployment Details | ||
We use Heroku for deploying our applications. The deployment process is automated via GitHub Actions using a Continuous Deployment (CD) pipeline. Every time we push changes to a branch associated with a specific app (e.g., frick, frack, beta, etc.), the CD.yml GitHub action is triggered, which initiates the deployment process. | ||
|
||
## Deployment Workflow Overview | ||
### Base Container Build: | ||
|
||
First, our base container image is built using the following command: | ||
bash | ||
```shell | ||
docker build -f Dockerfile.commonwealth_base -t commonwealth_base . | ||
``` | ||
This image contains the core setup required by all of our apps, ensuring consistency and reducing redundancy across different services. | ||
### Individual Process Builds: | ||
|
||
After building the base container, the individual process-specific Dockerfiles (e.g., Dockerfile.web, Dockerfile.evm_ce) are built and pushed to Heroku using the following command: | ||
bash | ||
```shell | ||
heroku container:push --recursive -a ${heroku_app_name} | ||
``` | ||
The --recursive flag ensures that all defined processes (web, consumer, evm_ce, etc.) are built and pushed to the appropriate Heroku app. | ||
### Release on Heroku: | ||
|
||
After the container images are successfully pushed, the next step is to release these images to Heroku: | ||
```shell | ||
heroku container:release web evm_ce consumer message_relayer knock -a ${heroku_app_name} | ||
``` | ||
This command releases the defined processes to their respective dynos on Heroku, making the application live. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"packageManager": "[email protected]", | ||
"scripts": { | ||
"build": "chmod u+x scripts/build.sh && ./scripts/build.sh", | ||
"docker-build-commonwealth": "docker build . --target commonwealth --tag commonwealth:latest", | ||
"docker-build-commonwealth": "docker build -f Dockerfile.commonwealth_base --tag commonwealth:latest .", | ||
"chromatic": "chromatic --exit-zero-on-changes", | ||
"clean": "chmod u+x scripts/clean-modules.sh && ./scripts/clean-modules.sh", | ||
"db-all": "pnpm -F commonwealth db-all", | ||
|
@@ -125,7 +125,6 @@ | |
"prettier-plugin-organize-imports": "^4.0.0", | ||
"process": "^0.11.10", | ||
"readline-sync": "^1.4.10", | ||
"sequelize-cli": "^6.2.0", | ||
"sharp": "^0.31.2", | ||
"sinon": "^15.0.4", | ||
"source-map-support": "^0.5.21", | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM commonwealth | ||
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register --max_old_space_size=$(./scripts/get-max-old-space-size.sh) build/server/workers/commonwealthConsumer/commonwealthConsumer.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM commonwealth | ||
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register --max_old_space_size=$(./scripts/get-max-old-space-size.sh) build/server/workers/evmChainEvents/startEvmPolling.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM commonwealth | ||
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register --max_old_space_size=$(./scripts/get-max-old-space-size.sh) build/server/workers/knock/knockWorker.js |
2 changes: 2 additions & 0 deletions
2
packages/commonwealth/deploy/dockerfiles/Dockerfile.message_relayer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM commonwealth | ||
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register --max_old_space_size=$(./scripts/get-max-old-space-size.sh) build/server/workers/messageRelayer/messageRelayer.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
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 && \ | ||
node --import=extensionless/register build/server/scripts/purgeCloudflareCache.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM commonwealth | ||
CMD NODE_ENV=production ./datadog-entrypoint.sh node --import=extensionless/register --max_old_space_size=$(./scripts/get-max-old-space-size.sh) --enable-source-maps ./build/server.js |
10 changes: 10 additions & 0 deletions
10
packages/commonwealth/deploy/environments/.env.public.commonwealth-beta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
UNLEASH_FRONTEND_SERVER_URL=https://flag.commonwealth.im/api/frontend | ||
UNLEASH_FRONTEND_API_TOKEN=*:development.309ede2a4ac83b15b51c0cd6b55acdc9f4edefeda5b6325e2414f9b0 | ||
HEROKU_APP_NAME=commonwealth-beta | ||
APP_ENV=beta | ||
NODE_ENV=production | ||
KNOCK_PUBLIC_API_KEY=pk_RLg22EIJ6jsuci6c7VvBU59gDQJZeFoeBKlOkgJLWvA | ||
KNOCK_IN_APP_FEED_ID=fc6e68e5-b7b9-49c1-8fab-6dd7e3510ffb | ||
SERVER_URL=https://qa.commonwealth.im | ||
MIXPANEL_DEV_TOKEN=312b6c5fadb9a88d98dc1fb38de5d900 | ||
MAGIC_PUBLISHABLE_KEY=pk_live_B0604AA1B8EEFDB4 |
7 changes: 7 additions & 0 deletions
7
packages/commonwealth/deploy/environments/.env.public.commonwealth-demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
UNLEASH_FRONTEND_SERVER_URL=https://flag.commonwealth.im/api/frontend | ||
UNLEASH_FRONTEND_API_TOKEN=*:development.309ede2a4ac83b15b51c0cd6b55acdc9f4edefeda5b6325e2414f9b0 | ||
HEROKU_APP_NAME=commonwealth-demo | ||
APP_ENV=demo | ||
NODE_ENV=production | ||
MIXPANEL_DEV_TOKEN=312b6c5fadb9a88d98dc1fb38de5d900 | ||
MAGIC_PUBLISHABLE_KEY=pk_live_EF89AABAFB87D6F4 |
10 changes: 10 additions & 0 deletions
10
packages/commonwealth/deploy/environments/.env.public.commonwealth-frack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
UNLEASH_FRONTEND_SERVER_URL=https://flag.commonwealth.im/api/frontend | ||
UNLEASH_FRONTEND_API_TOKEN=*:development.309ede2a4ac83b15b51c0cd6b55acdc9f4edefeda5b6325e2414f9b0 | ||
HEROKU_APP_NAME=commonwealth-frack | ||
APP_ENV=frack | ||
NODE_ENV=production | ||
SERVER_URL=https://commonwealth-frack.herokuapp.com | ||
KNOCK_PUBLIC_API_KEY=pk_EkjqgrIByZo85tIqdBkCmihVBtTB_ixY_37oTG_Au1Y | ||
KNOCK_IN_APP_FEED_ID=fc6e68e5-b7b9-49c1-8fab-6dd7e3510ffb | ||
MIXPANEL_DEV_TOKEN=312b6c5fadb9a88d98dc1fb38de5d900 | ||
MAGIC_PUBLISHABLE_KEY=pk_live_B0604AA1B8EEFDB4 |
8 changes: 8 additions & 0 deletions
8
packages/commonwealth/deploy/environments/.env.public.commonwealth-frick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
UNLEASH_FRONTEND_SERVER_URL=https://flag.commonwealth.im/api/frontend | ||
UNLEASH_FRONTEND_API_TOKEN=*:development.309ede2a4ac83b15b51c0cd6b55acdc9f4edefeda5b6325e2414f9b0 | ||
HEROKU_APP_NAME=commonwealth-frick | ||
APP_ENV=frick | ||
NODE_ENV=production | ||
SERVER_URL=https://commonwealth-frick.herokuapp.com | ||
MIXPANEL_DEV_TOKEN=312b6c5fadb9a88d98dc1fb38de5d900 | ||
MAGIC_PUBLISHABLE_KEY=pk_live_EF89AABAFB87D6F4 |
Oops, something went wrong.