Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: client distribution build script #534

Merged
merged 2 commits into from
Jan 4, 2022
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/state.json
**/README.md
**/.git
**/.gitignore
**/data
**/test
**/uploads
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/build-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build client
on:
workflow_dispatch:
workflow_call:
jobs:
builder:
name: builder
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Install uglify-js
run: npm install -g uglify-js
-
name: Create distribution
working-directory: ./client
run: ./build.sh
-
name: Upload distribution
uses: actions/upload-artifact@v2
with:
name: client-dist
path: ./client/dist


80 changes: 59 additions & 21 deletions .github/workflows/pub-docker.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
name: Publish Docker images
env:
DOCKERHUB_REPOSITORY: nuwcdivnpt/stig-manager
on:
workflow_dispatch:
jobs:
build-client:
uses: nuwcdivnpt/stig-manager/.github/workflows/build-client.yml@main
build-push-alpine:
name: Build and push from Alpine base
needs: build-client
runs-on: ubuntu-latest
steps:
- name: Check out the repo
-
name: Check out the repo
uses: actions/checkout@v2
- name: Get repository metadata
with:
ref: main
fetch-depth: 0
-
name: Download client distribution
uses: actions/download-artifact@v2
with:
name: client-dist
path: ./client/dist
-
name: Get repository metadata
id: repo
uses: actions/github-script@v3
with:
script: |
const repo = await github.repos.get(context.repo)
return repo.data
- name: Prepare variables
-
name: Prepare variables
id: prep
run: |
git fetch --prune --unshallow
DOCKER_IMAGE=nuwcdivnpt/stig-manager
DOCKER_IMAGE=${{ env.DOCKERHUB_REPOSITORY }}
BRANCH=$(git symbolic-ref --short HEAD)
SHA=$(git rev-parse --short=10 HEAD)
DESCRIBE=$(git describe --tags)
Expand All @@ -31,14 +47,17 @@ jobs:
echo ::set-output name=tags::${TAGS}
echo ::set-output name=describe::${DESCRIBE}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_ORG_OWNER_USERNAME }}
password: ${{ secrets.DOCKERHUB_ORG_OWNER_PW }}
- name: Build and push
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
Expand All @@ -61,34 +80,48 @@ jobs:
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ steps.prep.outputs.describe }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
- name: Image digest
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Update Docker Hub Description
-
name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_ORG_OWNER_USERNAME }}
password: ${{ secrets.DOCKERHUB_ORG_OWNER_PW }}
repository: nuwcdivnpt/stig-manager
repository: ${{ env.DOCKERHUB_REPOSITORY }}
short-description: An API and Web client for managing STIG assessments.
readme-filepath: ./docs/the-project/DockerHub_Readme.md
build-push-ironbank:
name: Build and push from Iron Bank base
needs: build-client
runs-on: ubuntu-latest
steps:
- name: Check out the repo
-
name: Check out the repo
uses: actions/checkout@v2
- name: Get repository metadata
with:
ref: main
fetch-depth: 0
-
name: Download client distribution
uses: actions/download-artifact@v2
with:
name: client-dist
path: ./client/dist
-
name: Get repository metadata
id: repo
uses: actions/github-script@v3
with:
script: |
const repo = await github.repos.get(context.repo)
return repo.data
- name: Prepare variables
-
name: Prepare variables
id: prep
run: |
git fetch --prune --unshallow
DOCKER_IMAGE=nuwcdivnpt/stig-manager
DOCKER_IMAGE=${{ env.DOCKERHUB_REPOSITORY }}
BRANCH=$(git symbolic-ref --short HEAD)
SHA=$(git rev-parse --short=10 HEAD)
DESCRIBE=$(git describe --tags)
Expand All @@ -100,20 +133,24 @@ jobs:
echo ::set-output name=tags::${TAGS}
echo ::set-output name=describe::${DESCRIBE}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_ORG_OWNER_USERNAME }}
password: ${{ secrets.DOCKERHUB_ORG_OWNER_PW }}
- name: Login to Iron Bank
-
name: Login to Iron Bank
uses: docker/login-action@v1
with:
registry: registry1.dso.mil
username: ${{ secrets.IRONBANK_USERNAME }}
password: ${{ secrets.IRONBANK_CLI_TOKEN }}
- name: Build and push
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
Expand All @@ -137,5 +174,6 @@ jobs:
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ steps.prep.outputs.describe }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
- name: Image digest
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# **/state.json
# **/README.md
# **/.git
# **/.gitignore
# **/data
# **/docs
# **/test
Expand All @@ -31,7 +32,8 @@ COPY --chown=node:node ./api/source .
RUN npm ci

RUN mkdir client
COPY --chown=node:node ./clients/extjs ./client
# Requires the client build files. Alternatively, copy ./client/src
COPY --chown=node:node ./client/dist ./client

RUN mkdir docs
COPY --chown=node:node ./docs/_build/html ./docs
Expand Down
127 changes: 127 additions & 0 deletions client/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/bin/bash

# STIG Manager client distribution build script
#
# Requires nodejs and npm to install uglify-js
# npm install -g uglify-js
#
# Build artifacts will created in ./dist

echo "Client build starting"

# Change to this script directory
cd "$(dirname "$(realpath "$0")")"

SrcDir=src
DistDir=dist

# Clean dist directory
echo "Cleaning $DistDir"
rm -rf $DistDir/*

# ExtJS
echo "Preparing ExtJS resources"
ExtResources="ext/adapter/ext/ext-base.js
ext/ext-all.js
ext/ux/GroupSummary.js
ext/resources/css/ext-all.css
ext/resources/css/xtheme-gray.css
ext/resources/images/default/button/arrow.gif
ext/resources/images/default/dd/drop-no.gif
ext/resources/images/default/grid/grid-split.gif
ext/resources/images/default/grid/loading.gif
ext/resources/images/default/shadow-c.png
ext/resources/images/default/shadow-lr.png
ext/resources/images/default/shadow.png
ext/resources/images/default/tree/loading.gif
ext/resources/images/gray/button/btn.gif
ext/resources/images/gray/form/trigger.gif
ext/resources/images/gray/grid/col-move-bottom.gif
ext/resources/images/gray/grid/col-move-top.gif
ext/resources/images/gray/grid/sort_asc.gif
ext/resources/images/gray/grid/sort_desc.gif
ext/resources/images/gray/panel/tool-sprites.gif
ext/resources/images/gray/panel/white-top-bottom.gif
ext/resources/images/gray/qtip/tip-anchor-sprite.gif
ext/resources/images/gray/qtip/tip-sprite.gif
ext/resources/images/gray/tabs/tab-close.gif
ext/resources/images/gray/window/icon-question.gif
ext/ux/fileuploadfield/css/fileuploadfield.css"
tar cf - -C $SrcDir --files-from <(echo "${ExtResources}") | tar xf - -C $DistDir

# CSS
echo "Preparing CSS resources"
cp -r $SrcDir/css $DistDir

# Fonts
echo "Preparing font resources"
cp -r $SrcDir/fonts $DistDir

# Images
echo "Preparing image resources"
cp -r $SrcDir/img $DistDir

# HTML
echo "Preparing HTML resources"
cp -r $SrcDir/index.html $DistDir/index.html

# JS
echo "Preparing JavaScript resources"
mkdir $DistDir/js
cp $SrcDir/js/init-dist.js $DistDir/js/init.js
cp $SrcDir/js/oidcProvider.js $DistDir/js
cp $SrcDir/js/Env.js.example $DistDir/js
cd $SrcDir
uglifyjs \
'js/SM/Global.js' \
'js/SM/TipContent.js' \
'js/SM/Ajax.js' \
'js/SM/Warnings.js' \
'js/SM/Classification.js' \
'js/SM/MainPanel.js' \
'js/SM/EventDispatcher.js' \
'js/FileUploadField.js' \
'js/MessageBox.js' \
'js/overrides.js' \
'js/RowEditor.js' \
'js/RowExpander.js' \
'js/SM/SelectingGridToolbar.js' \
'js/SM/NavTree.js' \
'js/SM/RowEditorToolbar.js' \
'js/SM/Collection.js' \
'js/SM/CollectionForm.js' \
'js/SM/CollectionAsset.js' \
'js/SM/CollectionStig.js' \
'js/SM/CollectionGrant.js' \
'js/SM/ColumnFilters.js' \
'js/SM/FindingsPanel.js' \
'js/SM/Assignments.js' \
'js/SM/asmcrypto.all.es5.js' \
'js/SM/Attachments.js' \
'js/SM/Exports.js' \
'js/SM/Parsers.js' \
'js/SM/Review.js' \
'js/SM/ReviewsImport.js' \
'js/SM/TransferAssets.js' \
'js/SM/Library.js' \
'js/SM/StigRevision.js' \
'js/library.js' \
'js/stigmanUtils.js' \
'js/userAdmin.js' \
'js/collectionAdmin.js' \
'js/collectionManager.js' \
'js/stigAdmin.js' \
'js/appDataAdmin.js' \
'js/adminTab.js' \
'js/completionStatus.js' \
'js/findingsSummary.js' \
'js/review.js' \
'js/collectionReview.js' \
'js/ExportButton.js' \
'js/jszip.min.js' \
'js/FileSaver.js' \
'js/fast-xml-parser.min.js' \
'js/jsonview.bundle.js' \
'js/stigman.js' -m -c > ../$DistDir/js/stig-manager.min.js

echo "Client build finished"
12 changes: 12 additions & 0 deletions client/dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Directory for the STIG Manager client distribution

# Content can be written here by executing:
# $ ../build.sh
#
# This file hopes to prevent commits to this directory

# Ignore everything in this directory
*

# Except this file
!.gitignore
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading