UNCLASSIFIED

Commit 8083b062 authored by Static Sites Deploy Bot's avatar Static Sites Deploy Bot
Browse files

Merge commit '4ddb6cfc0f4fa5a1dd70d3ffbac28b4a1ea4deb6' as 'static-sites'

parents 1ab8c9dd 50e3d4f2

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -4,4 +4,9 @@
**/node_modules
**/videos
**/*.lock
\ No newline at end of file
**/*.lock
/.vs/slnx.sqlite
/.vs/static-sites/config/applicationhost.config
/.vs/ProjectSettings.json
/.vs/static-sites/v16/.suo
/.vs/VSWorkspaceState.json
image: alpine:latest
stages:
#- test deps
- cypress e2e
- staging
- deploy
- after-copy
#- auto_MR
include:
- project: 'platform-one/private/big-bang/pipeline-templates'
ref: auto-merge
file: '/jobs/promote/copy-static-site.yml'
variables:
SITE_NAME: sso-info
OUTPUT_FOLDER: p1-sso/dist
DEPLOY_REPO: https://ent-collab-bot:${CI_STATIC_SITES_TOKEN}@repo1.dso.mil/platform-one/apps/static-sites.git
#cache:
# key: ${CI_COMMIT_REF_SLUG}
# paths:
# - /**/.npm
# - /**/node_modules
.job_template:
image: registry.dso.mil/platform-one/private/big-bang/pipeline-templates/ext-cypress:v0.2.0
stage: cypress e2e
#artifacts:
# when: always
# paths:
# - /**/cypress/videos/**/*.mp4
# - /**/cypress/screenshots/**/*.png
# expire_in: 3 day
# actual job definitions
# all steps are the same, they come from the template above
sso-info tests:
extends: .job_template
script:
- cd p1-sso
- npm i
# start the server in the background
- npm test
tags:
- p1
code-ship:
image: registry.dso.mil/platform-one/private/big-bang/pipeline-templates/ext-cypress:v0.2.0
extends: .copy-site
script:
- echo 'code shipping to static-sites deployment'
# run your code to produce prod artifacts
- cd p1-sso
- npm install -D
- npm run build
tags:
- p1
publish-staging:
image: registry.dso.mil/platform-one/private/big-bang/pipeline-templates/ext-cypress:v0.2.0
extends: .copy-staging-site
script:
- echo 'Publishing build outputs to MR for staging pre-prod'
- cd p1-sso
- npm install -D
- npm run build
tags:
- p1
staging-mr:
variables:
TARGET_BRANCH: staging
extends: .auto-mr
script:
- echo 'running auto merge request for staging'
- echo "Opening Merge request for ${GITLAB_USER_NAME}"
- cd p1-sso
tags:
- p1
deploy-mr:
variables:
TARGET_BRANCH: master
extends: .auto-mr
script:
- echo 'running auto merge request for master'
- echo "Opening Merge request for ${GITLAB_USER_NAME}"
- cd p1-sso
tags:
- p1
#auto create a merge request after a new commit
#create_merge_request:
# stage: auto_MR
# script:
# - echo Merge request opened by $GITLAB_USER_NAME
# - cd p1-sso
# - chmod +x ./auto_MR.sh
# - ./auto_MR.sh
ref: master
file: '/products/platform1/static-sites.yml'
## Platform One SSO Information Static Site
## Platform One Static Sites
Getting started:
This app deploys static sites into a NGINX container and relies on Istio VirtualServices to do the necessary routing for each site. Tests should be performed in the source repository and results of build/compilation (if applicable) pushed into `sites/<SITENAME>` directory.
```cd p1-sso && npm i```
### Updating a Site
Run p1-sso:
- Update the contenst of `sites/<SITENAME>`
- Submit a merge request
- A maintainer will merge into master and the site will automatically update in production within a couple minutes
```npm start```
### Adding a New Site
Run cypress tests:
- Create the directory with the content under `sites/<SITENAME>`
- Submit a merge request
- A maintainer will merge into master and will need to create the necessary Istio VirtualService in the consuming cluster
### Istio VirtualService Template
We use a VirtualService to map the site to the correct location and bind to specific domains, see below for an example. Note the unique elements:
- `name:`
- `uri:`
- `hosts:`
### route-bespin.yaml:
```
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bespin
spec:
hosts:
- "bespin.t-rex.dsop.io"
- "bespin.preprod.dsop.io"
- "bespin.il2.dsop.io"
- "bespin.af.mil"
gateways:
- public-gateway.istio-system.svc.cluster.local
http:
- match:
- uri:
prefix: /
rewrite:
uri: /bespin/
route:
- destination:
host: nginx
port:
number: 80
```
```npm test```
FROM registry.dsop.io/platform-one/apps/static-sites/nginx:1.19.0-ironbank-18
# NGINX blows up a lot of other stuff if not root, the config changes the actual user to nginx
USER root
COPY nginx.conf /etc/nginx/nginx.conf
RUN mkdir -p /upstream/sync/sites
\ No newline at end of file
worker_processes 1;
user nginx;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
error_log /dev/stdout info;
sendfile on;
keepalive_timeout 65;
server {
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /upstream/sync/sites;
error_page 404 /404.html;
location / {
try_files $uri $uri/ $uri/index.html =404;
}
}
}
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 2
strategy:
type: RollingUpdate
template:
spec:
containers:
- name: git-sync
image: k8s.gcr.io/git-sync:v3.1.3
resources:
limits:
memory: "128Mi"
cpu: "500m"
envFrom:
- configMapRef:
name: git-sync
volumeMounts:
- name: content
mountPath: /upstream/
- name: static-site
image: registry.dsop.io/platform-one/apps/static-sites:v0.3.4
ports:
- containerPort: 80
protocol: TCP
resources:
limits:
cpu: 500m
memory: 2500Mi
requests:
cpu: 20m
memory: 100Mi
readinessProbe:
httpGet:
path: /ready.html
port: 80
initialDelaySeconds: 15
timeoutSeconds: 1
volumeMounts:
- name: content
mountPath: /upstream/
volumes:
- name: content
emptyDir: {}
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: static-site
commonLabels:
app: nginx
resources:
- namespace.yaml
- deployment.yaml
- service.yaml
configMapGenerator:
- name: git-sync
literals:
- GIT_SYNC_REPO=https://repo1.dsop.io/platform-one/apps/static-sites.git
- GIT_SYNC_WAIT=60
- GIT_SYNC_ROOT=/upstream/
- GIT_SYNC_DEST=sync
apiVersion: v1
kind: Namespace
metadata:
name: static-site
labels:
istio-injection: enabled
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- name: http
port: 80
targetPort: 80
type: ClusterIP
# Ignore these file types
*.DS_Store
**/node_modules
**/videos
**/*.lock
**/dist/
**/static-sites
# P1 SSO
This is the public facing website for the Platform One SSO guide for the transition phase.
v1.0.3 - Changed website to be IL-agnostic (Jason Taylor)
v1.0.4 - Fixed NPM P1SSO_home.js test
v1.0.5 - Minor info change for certain bases not working, migration date
# How to merge changes into static sties
0. Download latest master (Clone first time, pull any other time)
>`git clone https://repo1.dso.mil/platform-one/plugins/website-sso-information.git` - Init the project and download dependencies (First time use)
>`git pull https://repo1.dso.mil/platform-one/plugins/website-sso-information.git` - Init the project and download dependencies (After first time use)
1. Checkout new branch
>`git checkout -b BRANCH-NAME` - Create new branch
2. Make and save changes
3. Test via NPM locally, if passes, continue. See below for commands
4. Tag your website to next tag (ONLY TAG AFTER YOU DO YOUR COMMITS. The Tag will only apply to changes made prior to tagging.)
>`git tag vX.X.X` - Tag to next command
5. Push commit via tag
>`git push origin v.X.X.X` - push
6. Create merge request for branch
7. Maintainer on Website project can merge changes
8. When pipeline finishes, create new MR on static sites for new tag
9. Check to see if your merge is editing correct website. If so, a maintainer on static sites can merge changes into repo.
### Some commands to get you started:
>`npm i` - Init the project and download dependencies
NOTE - you may need to install cypress separately if `npm i` doesn't install cypress for you:
```
npm install cypress --save-dev
```
or
```
yarn add cypress --dev
```
>`npm start` - Runs a minimal webserver and loads the static content
>`npm test` - Starts the static site and executes the cypress tests
>`npm run cypress` - Starts the static site and opens the cypress test harness
>`npm run build` - Package and copy output to dist folder
{
"integrationFolder":"tests/cypress",
"baseUrl": "http://localhost:3000",
"env": {
"key":"value"
}
}
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
\ No newline at end of file
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
This diff is collapsed.
{
"devDependencies": {
"copy-webpack-plugin": "^6.0.2",
"cypress": "^4.7.0",
"http-server": "^0.12.3",
"start-server-and-test": "^1.11.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"scripts": {
"start": "http-server -p 3000 src/public",
"cy:run": "cypress run",
"cy:open": "cypress open",
"test": "start-server-and-test start http://localhost:3000 cy:run",
"cypress": "start-server-and-test start http://localhost:3000 cy:open",
"build": "npx webpack --config webpack.config.js"
},
"dependencies": {}
}
describe('Basic Platform One Static Sites - p1sso', function() {
it('Visits the p1sso page', function() {
cy.visit("/")
})
it('has a valid home anchor tag', function() {
cy.get('a.navbar-brand').should('contain', 'PLATFORM ONE SSO')
})
it('has a valid header link', function() {
cy.get('#navbarResponsive > ul > li:nth-child(1) > a').should('contain', 'What is P1 SSO?')
})
})
\ No newline at end of file
describe('Verify home page', function() {
it('Title of page', function() {
cy.visit("/")
cy.title().should('eq','Platform One SSO')
})
it('Text', function() {
cy.get('.text-center')
cy.contains('The transition')
})
it('Graphic', function() {
cy.get('.screen').should('be.visible')
})
})
describe ('Verify header links' , function(){
it('What is P1 SSO link', function() {
cy.get('#whatisp1sso').click
cy.get('#whatisp1sso > :nth-child(1) > .row > .col-md-8 > .section-heading').should('be.visible')
})
it('What do I need to do?', function() {
cy.get('#whatdoineedtodo').click
cy.get('#whatdoineedtodo > :nth-child(1) > .row > .col-md-8 > h2.section-heading').should('be.visible')
})
it('FAQ', function() {
cy.get('#faq').click
cy.get('#faq > :nth-child(1) > .row > .col-md-8 > .section-heading').should('be.visible')
})
/* navigate to New SSO Account page, navigate back
it('New SSO Account', function() {
cy.get(':nth-child(4) > .nav-link').click
cy.get('.text-center')
cy.contains('Create a new account')
})*/
// it('Feedback', function() {
// cy.get('#feedback').click
// cy.get('#feedback > .container > .row > .col-md-8 > .section-heading').should('be.visible')
// })
})
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment