Skip to content

Commit 03b71f5

Browse files
author
Sean Sundberg
authored
Update dev mode for UI (#147)
* Update dev mode for UI * Update dockerfile * Fix dockerfile npm install commands * Update npm ci command * Clean up logic to OAuth requirement for dev/test Signed-off-by: Sean Sundberg <seansund@us.ibm.com>
1 parent 1126124 commit 03b71f5

11 files changed

Lines changed: 2389 additions & 1466 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"

.github/release-drafter.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
4+
categories:
5+
- title: 'Features'
6+
labels:
7+
- 'feature'
8+
- 'enhancement'
9+
- title: 'Bug Fixes'
10+
labels:
11+
- 'fix'
12+
- 'bugfix'
13+
- 'bug'
14+
- title: 'Maintenance'
15+
label: 'chore'
16+
version-resolver:
17+
major:
18+
labels:
19+
- 'major'
20+
minor:
21+
labels:
22+
- 'minor'
23+
patch:
24+
labels:
25+
- 'patch'
26+
default: patch
27+
template: |
28+
$CHANGES
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Docker build
2+
3+
# Controls when the workflow will run
4+
on:
5+
release:
6+
types:
7+
- published
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v2
22+
23+
- name: Set up Docker Buildx
24+
id: buildx
25+
uses: docker/setup-buildx-action@v2
26+
27+
- name: Login to Docker Hub
28+
uses: docker/login-action@v2
29+
with:
30+
username: ${{ secrets.DOCKER_USER }}
31+
password: ${{ secrets.DOCKER_TOKEN }}
32+
33+
- name: Login to CNTK Quay
34+
uses: docker/login-action@v2
35+
with:
36+
registry: quay.io
37+
username: ${{ secrets.QUAY_CNTK_USERNAME }}
38+
password: ${{ secrets.QUAY_CNTK_TOKEN }}
39+
40+
- name: Setup variables
41+
id: variables
42+
shell: bash
43+
run: |
44+
LATEST_ENABLED="true"
45+
46+
RELEASE_TAG=${GITHUB_REF#refs/tags/}
47+
RELEASE_TAG_ENABLED="false"
48+
if [[ "${GITHUB_REF}" =~ refs/tags ]] && [[ "${RELEASE_TAG}" != "main" ]]; then
49+
RELEASE_TAG_ENABLED="true"
50+
else
51+
RELEASE_TAG="main"
52+
fi
53+
54+
echo "Release tag: ${RELEASE_TAG}"
55+
echo "release-tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
56+
57+
echo "Release tag enabled: $RELEASE_TAG_ENABLED"
58+
echo "release-tag-enabled=$RELEASE_TAG_ENABLED" >> $GITHUB_OUTPUT
59+
60+
echo "Latest enabled: $LATEST_ENABLED"
61+
echo "latest-enabled=$LATEST_ENABLED" >> $GITHUB_OUTPUT
62+
63+
- name: Docker CNTK meta
64+
id: cntk-meta
65+
uses: docker/metadata-action@v4
66+
with:
67+
# list of Docker images to use as base name for tags
68+
images: |
69+
${{vars.IMAGE_BASE}}
70+
# Docker tags based on the following events/attributes
71+
tags: |
72+
type=raw,value=${{ steps.variables.outputs.release-tag }},enable=${{ steps.variables.outputs.release-tag-enabled }}
73+
type=raw,value=latest
74+
75+
- name: Build and push
76+
uses: docker/build-push-action@v3
77+
with:
78+
context: .
79+
file: Dockerfile
80+
push: ${{ github.event_name != 'pull_request' }}
81+
platforms: linux/amd64,linux/arm64
82+
tags: ${{ steps.cntk-meta.outputs.tags }}
83+
labels: ${{ steps.cntk-meta.outputs.labels }}
84+
85+
notify:
86+
needs: ["build"]
87+
runs-on: ubuntu-latest
88+
if: ${{ github.event_name != 'pull_request' }}
89+
90+
strategy:
91+
matrix:
92+
repo:
93+
- ${{ github.repository }}
94+
95+
steps:
96+
- name: Repository dispatch ${{ matrix.repo }}
97+
uses: cloud-native-toolkit/action-repository-dispatch@main
98+
with:
99+
notifyRepo: ${{ matrix.repo }}
100+
eventType: released
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.TOKEN }}

.github/workflows/release.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release module
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on:
6+
push:
7+
branches: [ main ]
8+
9+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
14+
# Steps represent a sequence of tasks that will be executed as part of the job
15+
steps:
16+
# Drafts your next Release notes as Pull Requests are merged into "master"
17+
- uses: rlespinasse/github-slug-action@v3.x
18+
19+
- uses: release-drafter/release-drafter@v5
20+
with:
21+
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
22+
config-name: release-drafter.yaml
23+
publish: true
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.TOKEN }}

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.access.redhat.com/ubi8/nodejs-16:1-72 as builder
1+
FROM registry.access.redhat.com/ubi8/nodejs-16:1-72 AS builder
22

33
USER root
44

@@ -10,7 +10,7 @@ USER default
1010
WORKDIR /opt/app-root/src
1111

1212
COPY --chown=default:root . .
13-
RUN npm install && \
13+
RUN npm ci && \
1414
npm run build
1515

1616
FROM registry.access.redhat.com/ubi8/nodejs-16-minimal:1-79
@@ -23,10 +23,10 @@ COPY --from=builder --chown=1001:0 /opt/app-root/src/dist ./dist
2323
COPY --chown=1001:0 package.json package-lock.json ./
2424
COPY --chown=1001:0 server ./server
2525

26-
RUN chmod -R g+w ./dist && \
27-
npm install --production
28-
2926
ENV NODE_ENV=production
27+
RUN chmod -R g+w ./dist
28+
RUN npm ci
29+
3030
ENV HOST=0.0.0.0 PORT=3000
3131

3232
EXPOSE 3000/tcp

config/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ const {
2929
OCP_OAUTH_CONFIG,
3030
} = process.env;
3131

32+
console.log('NODE_ENV: ', NODE_ENV)
33+
3234
// Generated configuration
3335
const isTest = NODE_ENV === 'test';
3436
const isDev = NODE_ENV !== 'production';
37+
const isProd = NODE_ENV === 'production';
3538
const internalUri =
3639
(PROTOCOL === 'https' && PORT === '443' && `${PROTOCOL}://${HOSTNAME}`) ||
3740
`${PROTOCOL}://${HOSTNAME}:${PORT}`;
@@ -45,7 +48,7 @@ let authConfig = {};
4548
try {
4649
authConfig = OCP_OAUTH_CONFIG ? JSON.parse(OCP_OAUTH_CONFIG) : JSON.parse(APPID_CONFIG);
4750
} catch (error) {
48-
if (!isTest) throw new Error(`Error parsing auth config ${OCP_OAUTH_CONFIG ? 'OCP_OAUTH_CONFIG' : 'APPID_CONFIG'} as json`)
51+
if (isProd) throw new Error(`Error parsing auth config ${OCP_OAUTH_CONFIG ? 'OCP_OAUTH_CONFIG' : 'APPID_CONFIG'} as json`)
4952
}
5053

5154
module.exports = {

docker-compose.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: '3'
2+
3+
services:
4+
ascent-ui:
5+
build: .
6+
environment:
7+
- API_HOST=http://ascent-bff:3001
8+
- EXTERNAL_PROTOCOL=http
9+
- EXTERNAL_HOSTNAME=localhost
10+
- EXTERNAL_PORT=3000
11+
- PROTOCOL=http
12+
- HOSTNAME=localhost
13+
- PORT=3000
14+
- NODE_ENV=test
15+
ports:
16+
- "3000:3000"
17+
depends_on:
18+
- ascent-bff
19+
# image: quay.io/cloudnativetoolkit/ascent-ui:0.0.77
20+
ascent-bff:
21+
image: quay.io/cloudnativetoolkit/ascent-bff:v1.0.1
22+
environment:
23+
- DATABASE_TEST={"connection":{"mongodb":{"composed":["mongodb://mongodb:27017/mongodb"],"authentication":{"username":"mongodb","password":"passw0rd"},"hosts":[{"hostname":"localhost","port":27017}],"database":"mongodb","query_options":{"authSource":"admin","tls":false}}}}
24+
- DATABASE_DEV={"connection":{"mongodb":{"composed":["mongodb://mongodb:27017/mongodb"],"authentication":{"username":"mongodb","password":"passw0rd"},"hosts":[{"hostname":"localhost","port":27017}],"database":"mongodb","query_options":{"authSource":"admin","tls":false}}}}
25+
- DATABASE={"connection":{"mongodb":{"composed":["mongodb://mongodb:27017/mongodb"],"authentication":{"username":"mongodb","password":"passw0rd"},"hosts":[{"hostname":"localhost","port":27017}],"database":"mongodb","query_options":{"authSource":"admin","tls":false}}}}
26+
command:
27+
- npm
28+
- run
29+
- serve:test
30+
ports:
31+
- "3001:3001"
32+
depends_on:
33+
- mongodb
34+
mongodb:
35+
image: docker.io/mongodb/mongodb-community-server:7.0.7-ubi9
36+
ports:
37+
- "25017:27017"
38+
environment:
39+
- MONGO_INITDB_ROOT_USERNAME=mongodb
40+
- MONGO_INITDB_ROOT_PASSWORD=passw0rd

0 commit comments

Comments
 (0)