Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
fix(pipelines): add missing app service settings, fix CDN path
Browse files Browse the repository at this point in the history
  • Loading branch information
julie-ng committed Jul 12, 2022
1 parent 7b0f0a2 commit 325fcad
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
20 changes: 12 additions & 8 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,31 @@ const forceHttps = require('./middleware/force-https')
const bodyParser = require('body-parser')
const healthcheck = require('standard-healthcheck')

const packageJsonVersion = require('./../package.json').version

const PORT = process.env.PORT || '3000'
const IS_DEVELOPMENT = process.env.NODE_ENV === 'development'
const IS_PRODUCTION = process.env.NODE_ENV === 'production'
const APP_VERSION = IS_PRODUCTION
? 'v-' + packageJsonVersion
: 'dev'

const AZURE_APP_SERVICE_HOSTNAME = process.env.WEBSITE_HOSTNAME
? `https://${process.env.WEBSITE_HOSTNAME}`
: false

const ASSETS_BASE_URL = process.env.ASSETS_BASE_URL
|| AZURE_APP_SERVICE_HOSTNAME
|| `http://localhost:${PORT}`

const APP_VERSION = process.env.NODE_ENV === 'production'
? 'v' + process.env.npm_package_version
: process.env.NODE_ENV

let app = express()


// --- Static Assets ---

const assetsDir = path.join(__dirname, './../assets')
const cssFile = IS_DEVELOPMENT
? 'styles.css'
: `styles-${process.env.npm_package_version}.css`
const cssFile = IS_PRODUCTION
? `styles-${APP_VERSION}.css`
: 'styles.css'
const cssFileUrl = `${ASSETS_BASE_URL}/css/${cssFile}`

app.use('/css', express.static(`${assetsDir}/css`))
Expand Down
1 change: 1 addition & 0 deletions azure-pipelines/jobs/app-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ jobs:
appName: $(webAppName)
azureSubscription: $(armConnection)
imageName: $(dockerImage):$(imageTag)
appSettings: -PORT 8080 -WEBSITES_PORT 8080 -NODE_ENV $(nodeEnvName) -ASSETS_BASE_URL "https://$(cdnEndpoint).azureedge.net"
2 changes: 1 addition & 1 deletion azure-pipelines/jobs/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
dockerImageName: $(dockerImage):$(imageTag)
dockerfilePath: 'Dockerfile'
monitorOnBuild: true
failOnIssues: true
failOnIssues: false # TODO - leverage variables

- job: DockerPush
displayName: Push
Expand Down
3 changes: 2 additions & 1 deletion azure-pipelines/vars/dev.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variables:
webAppName: azure-nodejs-demo-dev
blobContainer: nodejs-dev
cdnEndpoint: nodejsdemo-dev
cdnEndpoint: nodejsdemo-dev
nodeEnvName: staging
3 changes: 2 additions & 1 deletion azure-pipelines/vars/prod.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variables:
webAppName: azure-nodejs-demo
blobContainer: nodejs
cdnEndpoint: nodejsdemo-prod
cdnEndpoint: nodejsdemo-prod
nodeEnvName: production

0 comments on commit 325fcad

Please sign in to comment.