Skip to content

Commit

Permalink
Push dashboard image in CI (#6307)
Browse files Browse the repository at this point in the history
  • Loading branch information
michellebrier authored Oct 11, 2023
1 parent 992a0af commit 5461496
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 159 deletions.
7 changes: 7 additions & 0 deletions .circleci/src/workflows/protocol-dashboard.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
when: << pipeline.parameters.run-protocol-dashboard-workflow >>
jobs:
- protocol-dashboard-init
- push-docker-image:
name: push-protocol-dashboard
context: [Vercel, dockerhub]
service: dashboard
filters:
branches:
only: /^main$/
- protocol-dashboard-build-staging:
requires:
- protocol-dashboard-init
Expand Down
1 change: 0 additions & 1 deletion protocol-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ADD src ./src
ADD public ./public
ADD scripts ./scripts
ADD types ./types
ADD configure-envs ./configure-envs

ENV DASHBOARD_BASE_URL="/dashboard/"
RUN npm install --legacy-peer-deps
40 changes: 0 additions & 40 deletions protocol-dashboard/configure-envs/configureEnv.cjs

This file was deleted.

111 changes: 0 additions & 111 deletions protocol-dashboard/configure-envs/configureLocalEnv.js

This file was deleted.

6 changes: 3 additions & 3 deletions protocol-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
},
"scripts": {
"publish-scripts": "./scripts/publishScripts.sh",
"configure-local-env": "node ./configure-envs/configureLocalEnv.js",
"configure-stage-env": "node ./configure-envs/configureEnv.cjs stage",
"configure-prod-env": "node ./configure-envs/configureEnv.cjs prod",
"configure-local-env": "node ./scripts/configureEnv.js dev",
"configure-stage-env": "node ./scripts/configureEnv.cjs stage",
"configure-prod-env": "node ./scripts/configureEnv.cjs prod",
"start": "vite",
"serve": "vite preview",
"start:dev:cloud": "npm run configure-local-env remote && ./node_modules/.bin/env-cmd -f .env.dev.local npm start",
Expand Down
155 changes: 155 additions & 0 deletions protocol-dashboard/scripts/configureEnv.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
const fs = require('fs')
const path = require('path')
const dotenv = require('dotenv')
require('dotenv').config()

if (process.argv.length < 3) {
console.error('Usage: node configureEnv.cjs <stage|prod|dev>')
process.exit(1)
}
const env = process.argv[2]
if (!(env === 'stage' || env === 'prod' || env === 'dev')) {
console.error("Invalid environment arg. Please use 'stage', 'prod', or 'dev'.")
process.exit(1)
}

const CONFIGURED_ENV_FILE = `.env.${env}.local`
if (env === 'stage' || env === 'prod') {
try {
const ENV_FILE = `.env.${env}`

const parsedEnv = dotenv.config({ path: path.join(__dirname, '..', ENV_FILE) })

if (parsedEnv.error) {
throw parsedEnv.error
}

let envString = Object.entries(parsedEnv.parsed)
.map(([key, value]) => `${key}=${value}`)
.join('\n')

const VITE_DASHBOARD_BASE_URL = process.env.DASHBOARD_BASE_URL || '/'
envString += `\nVITE_DASHBOARD_BASE_URL=${VITE_DASHBOARD_BASE_URL}`
console.log(`Protocol dashboard base path: ${VITE_DASHBOARD_BASE_URL}`)

const configuredEnv = path.join(__dirname, '..', CONFIGURED_ENV_FILE)
fs.writeFile(configuredEnv, envString, err => {
if (err) {
console.error(err)
}
console.log(`Successfully configured ${CONFIGURED_ENV_FILE}`)
})
} catch (e) {
console.error(`Could not configure ${env} env:`, e)
}
} else if (env === 'dev') {
const AUDIUS_CONFIG = '.audius/config.json'
const AUDIUS_ETH_CONFIG = '.audius/eth-config.json'
const AUDIUS_SOL_CONFIG = '.audius/solana-program-config.json'

const homeDir = require('os').homedir()
try {
const configFile = require(path.join(homeDir, AUDIUS_CONFIG))
const ethConfigFile = require(path.join(homeDir, AUDIUS_ETH_CONFIG))
const solConfigFile = require(path.join(homeDir, AUDIUS_SOL_CONFIG))
console.log(configFile)
console.log(ethConfigFile)
console.log(solConfigFile)

const remoteHost = process.env.AUDIUS_REMOTE_DEV_HOST
const localhost = '0.0.0.0'
const useRemoteHost =
remoteHost && process.argv.length > 3 && process.argv[3] === 'remote'
const host = useRemoteHost ? remoteHost : localhost

const VITE_DASHBOARD_BASE_URL = process.env.DASHBOARD_BASE_URL || '/'
const VITE_ENVIRONMENT = 'development'
const VITE_CONTENT_NODE = `http://${host}:4000`
const VITE_DISCOVERY_PROVIDER = `http://${host}:5000`
const VITE_IDENTITY_SERVICE = `http://${host}:7000`
const VITE_IPFS_GATEWAY = `http://${host}:8080/ipfs/`

const VITE_REGISTRY_ADDRESS = configFile.registryAddress
const VITE_WEB3_PROVIDER_URL = `http://${host}:8545`
const VITE_OWNER_WALLET = configFile.ownerWallet

const VITE_ETH_REGISTRY_ADDRESS = ethConfigFile.registryAddress
const VITE_ETH_PROVIDER_URL = `http://${host}:8546`
const VITE_ETH_TOKEN_ADDRESS = ethConfigFile.audiusTokenAddress
const VITE_ETH_OWNER_WALLET = ethConfigFile.ownerWallet
// Chain id is 1337 for local eth ganache because we are ... leet
const VITE_ETH_NETWORK_ID = 1337

const VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS =
solConfigFile.claimableTokenAddress
const VITE_REWARDS_MANAGER_PROGRAM_ID =
solConfigFile.rewardsManagerAddress
const VITE_REWARDS_MANAGER_PROGRAM_PDA =
solConfigFile.rewardsManagerAccount
const VITE_REWARDS_MANAGER_TOKEN_PDA =
solConfigFile.rewardsManagerTokenAccount
const VITE_SOLANA_TOKEN_PROGRAM_ADDRESS =
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
const VITE_SOLANA_WEB3_CLUSTER = 'devnet'
const VITE_SOLANA_CLUSTER_ENDPOINT = `http://${host}:8899`
const VITE_WAUDIO_MINT_ADDRESS = solConfigFile.splToken
const VITE_SOLANA_FEE_PAYER_ADDRESS = solConfigFile.feePayerWalletPubkey

const VITE_AUDIUS_URL = `http://${host}:3000`
const VITE_GQL_URI = `http://${host}:8000/subgraphs/name/AudiusProject/audius-subgraph`

const VITE_IDENTITY_SERVICE_ENDPOINT = `http://${host}:7000`

const contents = `
# DO NOT MODIFY. SEE /scripts/configureEnv.cjs
VITE_DASHBOARD_BASE_URL=${VITE_DASHBOARD_BASE_URL}
VITE_ENVIRONMENT=${VITE_ENVIRONMENT}
VITE_DISCOVERY_PROVIDER=${VITE_DISCOVERY_PROVIDER}
VITE_CONTENT_NODE=${VITE_CONTENT_NODE}
VITE_IDENTITY_SERVICE=${VITE_IDENTITY_SERVICE}
VITE_IPFS_GATEWAY=${VITE_IPFS_GATEWAY}
VITE_REGISTRY_ADDRESS=${VITE_REGISTRY_ADDRESS}
VITE_WEB3_PROVIDER_URL=${VITE_WEB3_PROVIDER_URL}
VITE_OWNER_WALLET=${VITE_OWNER_WALLET}
VITE_ETH_REGISTRY_ADDRESS=${VITE_ETH_REGISTRY_ADDRESS}
VITE_ETH_PROVIDER_URL=${VITE_ETH_PROVIDER_URL}
VITE_ETH_TOKEN_ADDRESS=${VITE_ETH_TOKEN_ADDRESS}
VITE_ETH_OWNER_WALLET=${VITE_ETH_OWNER_WALLET}
VITE_ETH_NETWORK_ID=${VITE_ETH_NETWORK_ID}
VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS=${VITE_CLAIMABLE_TOKEN_PROGRAM_ADDRESS}
VITE_SOLANA_TOKEN_PROGRAM_ADDRESS=${VITE_SOLANA_TOKEN_PROGRAM_ADDRESS}
VITE_SOLANA_CLUSTER_ENDPOINT=${VITE_SOLANA_CLUSTER_ENDPOINT}
VITE_SOLANA_WEB3_CLUSTER=${VITE_SOLANA_WEB3_CLUSTER}
VITE_WAUDIO_MINT_ADDRESS=${VITE_WAUDIO_MINT_ADDRESS}
VITE_SOLANA_FEE_PAYER_ADDRESS=${VITE_SOLANA_FEE_PAYER_ADDRESS}
VITE_REWARDS_MANAGER_PROGRAM_ID=${VITE_REWARDS_MANAGER_PROGRAM_ID}
VITE_REWARDS_MANAGER_PROGRAM_PDA=${VITE_REWARDS_MANAGER_PROGRAM_PDA}
VITE_REWARDS_MANAGER_TOKEN_PDA=${VITE_REWARDS_MANAGER_TOKEN_PDA}
VITE_AUDIUS_URL=${VITE_AUDIUS_URL}
VITE_GQL_URI=${VITE_GQL_URI}
VITE_IDENTITY_SERVICE_ENDPOINT=${VITE_IDENTITY_SERVICE_ENDPOINT}
`

// Note .env.development.local takes precidence over .env.development
// https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables
fs.writeFile(CONFIGURED_ENV_FILE, contents, err => {
if (err) {
console.error(err)
}
console.log(`Successfully configured ${CONFIGURED_ENV_FILE}`)
})
} catch (e) {
console.error(`
Did not find configuration file.
See https://github.com/AudiusProject/audius-e2e-tests to configure a local dev environment.
`, e)
}
}
8 changes: 4 additions & 4 deletions protocol-dashboard/scripts/updateBuild.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ const pinFromFs = async (cid) => {
name: `Dashboard build ${env} ${cid} - ${new Date().toISOString()}`
}
}
const sourcePath = '/home/circleci/protocol-dashboard/dist'
const sourcePath = '/home/circleci/audius-protocol/protocol-dashboard/dist'
try {
const result = await pinata.pinFromFS(sourcePath, options)
console.log(result);
console.log(result)
} catch (e) {
console.log(err);
console.log(e)
}
}

Expand All @@ -83,4 +83,4 @@ const run = async () => {
}
}

run()
run()

0 comments on commit 5461496

Please sign in to comment.