diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..c3dbbbcf5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +# Hidden files and folders +.* +.*/ + +# Test folder +e2e/ + +# Dependencies and build folders +node_modules/ + +# Non-build related files +README.md +logo.png +karm.conf.js +protractor.conf.js +proxy.conf.js + diff --git a/.github/workflows/deploy-frontend-whitesource.yml b/.github/workflows/deploy-frontend-whitesource.yml new file mode 100644 index 000000000..66a66c963 --- /dev/null +++ b/.github/workflows/deploy-frontend-whitesource.yml @@ -0,0 +1,67 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +on: + push: + branches: + - '*' + workflow_dispatch: + +jobs: + build-and-deploy: + name: Build and deploy + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js version + uses: actions/setup-node@v1 + with: + node-version: '14.x' + + - name: npm install, build, and test + run: | + # Build and test the project, then + # deploy to Azure Web App. + npm install + npm run build --if-present + #npm run test --if-present + + - name: WhiteSource Unified Agent Scan + env: + WS_APIKEY: ${{secrets.APIKEY}} + WS_USERKEY: ${{secrets.USERKEY}} + WS_WSS_URL: https://app.whitesourcesoftware.com/agent + WS_PRODUCTNAME: ${{github.event.repository.name}} + WS_PROJECTNAME: ${{github.ref}} + WS_FILESYSTEMSCAN: false + WS_GENERATEPROJECTDETAILSJSON: true + WS_UPDATEINVENTORY: true #(defaults to true) + WS_enableImpactAnalysis: true + WS_resolveAllDependencies: false + run: | + sudo apt-get install jq curl + echo Downloading WhiteSource Unified Agent + curl -LJO https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar + if [[ "$(curl -sL https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar.sha256)" != "$(sha256sum wss-unified-agent.jar)" ]] ; then + echo "Integrity Check Failed" + else + echo "Integrity Check Passed" + echo Starting WhiteSource Scan + java -jar wss-unified-agent.jar + fi + - name: Archive Whitesource results + uses: actions/upload-artifact@v3 + with: + name: Whitesource reports + path: ./whitesource + + + # - name: 'Deploy to Azure Web App' + # id: deploy-to-webapp + # uses: azure/webapps-deploy@v2 + # with: + # app-name: angular-essentials-demo + # publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + # package: dist/ diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.yml new file mode 100644 index 000000000..59aac7fd5 --- /dev/null +++ b/.github/workflows/deploy-frontend.yml @@ -0,0 +1,37 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +on: + push: + branches: + - '*' + workflow_dispatch: + +jobs: + build-and-deploy: + name: Build and deploy + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js version + uses: actions/setup-node@v1 + with: + node-version: '14.x' + + - name: npm install, build, and test + run: | + # Build and test the project, then + # deploy to Azure Web App. + npm install + npm run build --if-present + #npm run test --if-present + + - name: 'Deploy to Azure Web App' + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: angular-essentials-demo + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + package: dist/ diff --git a/.whitesource b/.whitesource new file mode 100644 index 000000000..25c829953 --- /dev/null +++ b/.whitesource @@ -0,0 +1,21 @@ +{ + "scanSettings": { + "configMode": "AUTO", + "configExternalURL": "", + "projectToken": "", + "baseBranches": [] + }, + "checkRunSettings": { + "vulnerableCheckRunConclusionLevel": "failure", + "displayMode": "diff" + }, + "issueSettings": { + "minSeverityLevel": "LOW", + "issueType": "DEPENDENCY" + }, + "remediateSettings": { + "workflowRules": { + "enabled": true + } + } +} \ No newline at end of file diff --git a/CNAME b/CNAME index e11dd95f3..d66dc0807 100644 --- a/CNAME +++ b/CNAME @@ -1 +1 @@ -angular.realworld.io +sample-frontend-angular-web-app diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..8c9a04f66 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:14.18-slim + +RUN mkdir /server +WORKDIR /server + +RUN npm install http-server -g + +COPY ./dist . + +EXPOSE 8080 + +CMD ["http-server"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..f5ba9b83a --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,14 @@ +services: + frontend: + build: + context: . + proxy: + image: nginx:1.17.4 + volumes: + - ./nginx/default.conf:/tmp/default.conf.template + command: ["/bin/bash", "-c", "envsubst < /tmp/default.conf.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"] + environment: + APP_SERVER: 'http://frontend:8080' + API_SERVER: '${API_SERVER:-http://host.docker.internal:8080}' + ports: + - "80:80" diff --git a/e2e/app.e2e-spec.ts b/e2e/app.e2e-spec.ts index 7bccf42fd..5209f74e3 100644 --- a/e2e/app.e2e-spec.ts +++ b/e2e/app.e2e-spec.ts @@ -11,4 +11,4 @@ describe('ng-demo App', () => { page.navigateTo(); expect(page.getParagraphText()).toContain('conduit'); }); -}); +}); \ No newline at end of file diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 000000000..502c563a3 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,13 @@ +server { + listen 80; + server_name localhost; + + location / { + proxy_pass ${APP_SERVER}; + } + + location /api { + rewrite /api/(.*) /$1 break; + proxy_pass ${API_SERVER}; + } +} diff --git a/package.json b/package.json index 67b2a54ee..25836d213 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "MIT", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "ng serve --proxy-config proxy.conf.js", "build": "ng build --configuration production --base-href ./ && cp CNAME dist/CNAME", "test": "ng test", "lint": "ng lint --force", @@ -58,4 +58,4 @@ "tslint": "~6.1.3", "typescript": "4.3.5" } -} \ No newline at end of file +} diff --git a/proxy.conf.js b/proxy.conf.js new file mode 100644 index 000000000..9f0cae580 --- /dev/null +++ b/proxy.conf.js @@ -0,0 +1,12 @@ +var PROXY_CONF = { + "/api": { + "target": process.env.API_URL || "http://localhost:8080", + "secure": true, + "pathRewrite": { + "^/api": "" + }, + "changeOrigin": true + } +} + +module.exports = PROXY_CONF \ No newline at end of file diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 4f9b30833..5031567b0 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,5 @@ export const environment = { production: true, - api_url: 'https://conduit.productionready.io/api' + // api_url: 'https://conduit.productionready.io/api' + api_url: '/api' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 81a83d65e..554954e62 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -5,5 +5,6 @@ export const environment = { production: false, - api_url: 'https://conduit.productionready.io/api' + // api_url: 'https://conduit.productionready.io/api' + api_url: '/api' }; diff --git a/src/main.ts b/src/main.ts index dd072d0b3..7ed1b57d2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,6 +8,7 @@ if (environment.production) { enableProdMode(); } + const bootstrapPromise = platformBrowserDynamic().bootstrapModule(AppModule); // Logging bootstrap information diff --git a/test.txt b/test.txt new file mode 100644 index 000000000..362d8d429 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +Test file to trigger whitesource diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 000000000..adb567aca --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,15 @@ +{ + "folders": [ + { + "path": ".." + }, + { + "path": "../../../Clients/ADP/terraform-azurerm-postgresql-flexible-server" + } + ], + "extensions": { + "recommendations": [ + "whitesource.whitesource-advise" + ] + } +} \ No newline at end of file