Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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
49 changes: 28 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,47 @@ git clone https://github.com/keymanapp/status.keyman.com
cd status.keyman.com/
```

Build status.keyman.com:
### Prerequisites

```bash
cd server
npm install
npm run-script build
cd ../public
npm install
npm run-script build
cd ..
```
* Docker Desktop
* On Windows, you'll need to have Git Bash installed in `C:\Program Files\git\bin\bash.exe`.

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`.
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]
```

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

## Development server
## Build the docker containers

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:
Build status.keyman.com, in development mode:

```bash
npm run start-server
./build.sh stop build --debug
Copy link
Copy Markdown
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)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Currently, --debug is not default.

```

and in the second, run:
## Start the development server

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

```bash
npm run start-client
./build.sh start --debug
```

* 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
* Point your browser to <http://localhost:8061> to view the live reload version
of the application.
* 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)

### @keymanapp-test-bot

Expand All @@ -54,3 +56,8 @@ Three files needed for development:
* `.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

## Production

This site is deployed to a Kubernetes cluster via configuration in a private
repo to status.keyman.com.
Empty file added _control/.keep
Empty file.
94 changes: 94 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/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"
# TODO: release updated bootstrap version!
readonly BOOTSTRAP_VERSION=feat/docker-support-for-status-site
[ -f "$BOOTSTRAP" ] && source "$BOOTSTRAP" || source <(curl -H "Cache-Control: no-cache" -fs https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh)
## END STANDARD SITE BUILD SCRIPT INCLUDE

#
# in development mode, the public host is on a separate port to reduce the
# complexity of tsc --watch vs nodemon; in the future we could consider
# consolidation into a single container. There is little benefit into splitting
# production into two containers, given production version of public is fully
# static on server side.
#

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
Copy Markdown
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
Copy Markdown
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