Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Dockerfile text eol=lf
*.Dockerfile text eol=lf
*.sh eol=lf
52 changes: 52 additions & 0 deletions .github/workflows/master_com-keyman-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App - com-keyman-status

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master

- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '22.x'

- name: npm ci + build - public
run: |
echo "- Building public for release"
cd public
npm ci
./node_modules/.bin/ng build --configuration production
cd ..

- name: npm ci + build - server
run: |
echo "- Building server for release"
cd server
npm ci
./node_modules/.bin/tsc
cd ..

- name: server test
run: |
cd server
npx mocha --import=./_mocha_register.js
cd ..

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
with:
app-name: 'com-keyman-status'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_29683e7e380246d28c473e1643a69a4d }}
package: .
52 changes: 52 additions & 0 deletions .github/workflows/staging_com-keyman-staging-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App - com-keyman-staging-status

on:
push:
branches:
- staging
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master

- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '22.x'

- name: npm ci + build - public
run: |
echo "- Building public for release"
cd public
npm ci
./node_modules/.bin/ng build --configuration production
cd ..

- name: npm ci + build - server
run: |
echo "- Building server for release"
cd server
npm ci
./node_modules/.bin/tsc
cd ..

- name: server test
run: |
cd server
npx mocha --import=./_mocha_register.js
cd ..

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
with:
app-name: 'com-keyman-staging-status'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_690026b08b4f4dd681d2a0118d60b619 }}
package: .
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ jobs:
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '20.x'
node-version: '22.x'

- name: npm install, build, and test
run: |
npm install
npm run build
npm run test
./build.sh configure build test --release
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
localenv.sh
node_modules/
.keymanapp-test-bot.*
local*.sh
local*.sh

# Shared files are bootstrapped:
resources/bootstrap.inc.sh*
resources/.bootstrap-version
resources/.bootstrap-registry
_common/

# State files
_control/debug
_control/release
_control/ready
104 changes: 76 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
# Quick Start
# status.keyman.com

## Overview

* Back end is a node server in `/server`.
* Front end is an Angular app in `/public`.
* The [Keyman Test-bot](https://github.com/keymanapp/keyman/wiki/User-Testing-Workflows)
(@keymanapp-test-bot) is in `/server/keymanapp-test-bot`.

The site is setup to run in Docker container(s).

The site can be setup in development (`--debug`) or production (`--release`)
modes. When in development mode, the front end is hosted (on
http://localhost:8061) in a separate container to the back end (on
http://localhost:8060) in order to facilitate live-reload on changes.

For production mode, the front end is compiled to static pages which are then
served by the back end (on http://localhost:8060).

## Prerequisites

* Docker Desktop
* On Windows, you'll need to have Git Bash installed in `C:\Program Files\git\bin\bash.exe`.

Before building and starting the site, you need to have API tokens set as
environment variables. These should be added in script `server/localenv.sh`.

```bash
export KEYMANSTATUS_TEAMCITY_TOKEN=[your personal auth token here]
export KEYMANSTATUS_GITHUB_TOKEN=[your personal auth token here]
export KEYMANSTATUS_SENTRY_TOKEN=[your personal auth token here]
```

### @keymanapp-test-bot

Three files are needed for development:

* `.keymanapp-test-bot.appid`: integer appid (e.g. 134443 for the normal test app)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I get that appid?

* `.keymanapp-test-bot.pem`: certificate for GitHub integration for app
* `.keymanapp-test-bot.secret`: secret for GitHub integration for app

## Development setup

Clone the repo:

Expand All @@ -7,50 +48,57 @@ git clone https://github.com/keymanapp/status.keyman.com
cd status.keyman.com/
```

Build status.keyman.com:
### Build the docker containers

Build status.keyman.com, in development mode:

```bash
cd server
npm install
npm run-script build
cd ../public
npm install
npm run-script build
cd ..
./build.sh stop build --debug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to specify --debug or is that the default (as it is with the builder scripts in the keyman repo)?

```

Before running the node server, you need to have two API tokens set as environment variables. You might want to add these to script `server/localenv.sh`.
### Start the development server

This repo is configured for live build and reload of both the client and server,
running in Docker.

```bash
export KEYMANSTATUS_TEAMCITY_TOKEN=[your personal auth token here]
export KEYMANSTATUS_GITHUB_TOKEN=[your personal auth token here]
export KEYMANSTATUS_SENTRY_TOKEN=[your personal auth token here]
./build.sh start --debug
```

On Windows, you'll also need to have Git Bash installed in `C:\Program Files\git\bin\bash.exe`.
* Point your browser to <http://localhost:8061> to view the live reload version
of the application.
* The site takes a moment to compile and load; you can watch the logs to see
when it is ready.

## Development server
### Running unit tests

This repo is configured for live build and reload of both the client and server. You'll need two terminals open. In the first, run:
The unit tests will currently stop the back end container before running.

```bash
npm run start-server
./build.sh test --debug
```

and in the second, run:
## Production setup

This site is deployed to a Kubernetes cluster via configuration in a private
repo to status.keyman.com.

You can run the production mode site locally with:

```bash
npm run start-client
./build.sh stop build start --release
```

* Point your browser to <http://localhost:4200> to view the live reload version of the application.
* The query parameter `?c=1` adds a contributions view which is not visible by default.
* Another query parameter `?sprint=P8S4` parameter to view sprint contributions data for P8S4

### @keymanapp-test-bot
* Point your browser to <http://localhost:8060> to view the production version
of the application.

Three files needed for development:
## Site query parameters

* `.keymanapp-test-bot.appid`: integer appid (e.g. 134443 for the normal test app)
* `.keymanapp-test-bot.pem`: certificate for GitHub integration for app
* `.keymanapp-test-bot.secret`: secret for GitHub integration for app
* The following query parameters are available:
* `?c=1` shows contributions at the top center
* `?o=1` shows owner for each platform
* `?a=1` shows build agent status at the top right
* `?r=1` adds a refresh button to force a server-side full refresh (this is
costly, so only press this when there has been a data error such as a
network failure making status data out of date; most errors are
actually self-healing)
Empty file added _control/.keep
Empty file.
89 changes: 89 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
## START STANDARD SITE BUILD SCRIPT INCLUDE
readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh"
readonly BOOTSTRAP_VERSION=v1.0.10
if ! [ -f "$BOOTSTRAP" ] || ! source "$BOOTSTRAP"; then
curl -H "Cache-Control: no-cache" --fail --silent --show-error -w "curl: Finished attempt to download %{url}" "https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh" -o "$BOOTSTRAP.tmp" || exit 1
source "$BOOTSTRAP.tmp"
rm -f "$BOOTSTRAP.tmp"
fi
## END STANDARD SITE BUILD SCRIPT INCLUDE

source _common/keyman-local-ports.inc.sh
source _common/docker.inc.sh

readonly HOST_STATUS_KEYMAN_COM=status.keyman.com.localhost

readonly THIS_CONTAINER_NAME=status-keyman-website
readonly PUBLIC_CONTAINER_NAME=status-keyman-public
readonly THIS_CONTAINER_DESC=status-keyman-com-app
readonly PUBLIC_CONTAINER_DESC=status-keyman-com-public
readonly THIS_IMAGE_NAME=status-keyman-website
readonly PUBLIC_IMAGE_NAME=status-keyman-public
readonly THIS_HOST="$HOST_STATUS_KEYMAN_COM"
readonly PUBLIC_HOST="$HOST_STATUS_KEYMAN_COM" # same host
readonly THIS_PORT="$PORT_STATUS_KEYMAN_COM"
readonly PUBLIC_PORT="$PORT_STATUS_KEYMAN_COM_PUBLIC"


################################ Main script ################################

builder_describe \
"Setup status.keyman.com site to run via Docker." \
configure \
clean \
build \
start \
stop \
test

builder_parse "$@"

function build_docker_containers() {
build_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $BUILDER_CONFIGURATION server.Dockerfile
if builder_is_debug_build; then
build_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME $BUILDER_CONFIGURATION public.Dockerfile
fi
}

function start_docker_containers() {
start_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $THIS_CONTAINER_DESC $THIS_HOST $THIS_PORT $BUILDER_CONFIGURATION
if builder_is_debug_build; then
start_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME $PUBLIC_CONTAINER_DESC $PUBLIC_HOST $PUBLIC_PORT $BUILDER_CONFIGURATION
fi
}

function stop_docker_containers() {
rm -f ./_control/ready
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't this be in clean_docker_containers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because once the site is down, it is no longer ready -- it could go in clean as well I guess?

stop_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME
# always stop all containers - even in release build
stop_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME
}

function clean_docker_containers() {
clean_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME
# always clean all containers - even in release build
clean_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME
}

function do_clean() {
clean_docker_containers
rm -rf ./server/node_modules ./server/dist
rm -rf ./public/node_modules ./public/angular ./public/dist
rm -rf ./public/angular
rm -rf ./_common
rm -rf ./resources/.bootstrap-registry ./resources/bootstrap-version ./resources/bootstrap.inc.sh
}

function test_docker_container() {
stop_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME
MSYS_NO_PATHCONV=1 start_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $THIS_CONTAINER_DESC $THIS_HOST $THIS_PORT $BUILDER_CONFIGURATION "/bin/sh" "./resources/test.sh"
}

builder_run_action configure bootstrap_configure
builder_run_action clean do_clean
builder_run_action stop stop_docker_containers
builder_run_action build build_docker_containers
builder_run_action start start_docker_containers
builder_run_action test test_docker_container
10 changes: 0 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
"name": "keyman-status",
"version": "1.0.0",
"description": "Report on status of Keyman projects",
"main": "server/dist/server/code.js",
"type": "module",
"scripts": {
"build": "npm run-script build-server && npm run-script build-client",
"build-client": "cd public && npm install && npm run-script build",
"build-server": "cd server && npm install && npm run-script build",
"start-client": "cd public && npm run-script start",
"start-server": "cd server && npm run-script start",
"test": "cd server && npx mocha --import=./_mocha_register.js",
"log": "az webapp log tail --resource-group keyman --name com-keyman-status"
},
"author": "Marc Durdin",
"license": "MIT"
}
13 changes: 13 additions & 0 deletions public.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# syntax=docker/dockerfile:1

FROM node:22@sha256:cd6fb7efa6490f039f3471a189214d5f548c11df1ff9e5b181aa49e22c14383e AS node-builder

WORKDIR /var/www/html

ARG BUILDER_CONFIGURATION="debug"
ENV BUILDER_CONFIGURATION=$BUILDER_CONFIGURATION

# DOCKER_RUNTIME_PUBLIC env var helps prevent the resource scripts running on the host
ENV DOCKER_RUNTIME_PUBLIC=1

CMD [ "/bin/sh", "./resources/start-public.sh" ]
Loading