Skip to content

Commit

Permalink
hard-code apiurl for prod, dev, stage and island to make auth work
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jul 6, 2024
1 parent 1cfc7fa commit 694aa15
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
- name: tag as latest and push to registry # (jcs) are explicit singularity push commands redundant? (see ./build.sh)
shell: bash
run: |
for CONTAINER in vcell-api vcell-rest vcell-webapp vcell-batch vcell-opt vcell-clientgen vcell-data vcell-db vcell-mongo vcell-sched vcell-submit vcell-admin;\
for CONTAINER in vcell-api vcell-rest vcell-webapp-prod vcell-webapp-dev vcell-webapp-stage vcell-webapp-island vcell-batch vcell-opt vcell-clientgen vcell-data vcell-db vcell-mongo vcell-sched vcell-submit vcell-admin;\
do docker tag ${VCELL_REPO_NAMESPACE}/$CONTAINER:${VCELL_TAG} ${VCELL_REPO_NAMESPACE}/$CONTAINER:latest;\
docker tag ${VCELL_REPO_NAMESPACE}/$CONTAINER:${VCELL_TAG} ${VCELL_REPO_NAMESPACE}/$CONTAINER:${{ steps.version.outputs.tag }};\
docker push --all-tags ${VCELL_REPO_NAMESPACE}/$CONTAINER;\
Expand Down
27 changes: 19 additions & 8 deletions docker/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,27 @@ build_rest() {
}


build_webapp() {
echo "building $repo/vcell-webapp:$tag"
echo "$SUDO_CMD docker buildx build --platform=linux/amd64 -f ../../webapp-ng/Dockerfile-webapp --tag $repo/vcell-webapp:$tag ../../webapp-ng"
$SUDO_CMD docker buildx build --platform=linux/amd64 -f ../../webapp-ng/Dockerfile-webapp --tag $repo/vcell-webapp:$tag ../../webapp-ng
if [[ $? -ne 0 ]]; then echo "docker buildx build --platform=linux/amd64 failed"; exit 1; fi
if [ "$skip_push" == "false" ]; then
$SUDO_CMD docker push $repo/vcell-webapp:$tag
fi
build_webapp_common() {
config=$1
echo "building $repo/vcell-webapp-${config}:$tag"
echo "$SUDO_CMD docker buildx build --platform=linux/amd64 -f ../../webapp-ng/Dockerfile-webapp-${config} --tag $repo/vcell-webapp-${config}:$tag ../../webapp-ng"
$SUDO_CMD docker buildx build --platform=linux/amd64 -f ../../webapp-ng/Dockerfile-webapp-${config} --tag $repo/vcell-webapp-${config}:$tag ../../webapp-ng
if [[ $? -ne 0 ]]; then echo "docker buildx build --platform=linux/amd64 failed"; exit 1; fi
if [ "$skip_push" == "false" ]; then
$SUDO_CMD docker push $repo/vcell-webapp-${config}:$tag
fi
}

build_webapp() {
build_webapp_common dev
if [[ $? -ne 0 ]]; then echo "failed to build dev"; exit 1; fi
build_webapp_common stage
if [[ $? -ne 0 ]]; then echo "failed to build stage"; exit 1; fi
build_webapp_common prod
if [[ $? -ne 0 ]]; then echo "failed to build prod"; exit 1; fi
build_webapp_common island
if [[ $? -ne 0 ]]; then echo "failed to build island"; exit 1; fi
}

build_batch() {
echo "building $repo/vcell-batch:$tag"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN npm install --legacy-peer-deps

COPY . .

RUN npm run build
RUN npm run build -c configuration_dev

# -----------------

Expand Down
24 changes: 24 additions & 0 deletions webapp-ng/Dockerfile-webapp-island
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Build stage
FROM node:20.11-alpine3.19 AS build

RUN apk update && apk add git

RUN mkdir -p /app

WORKDIR /app

COPY package.json .
COPY package-lock.json .

RUN npm install --legacy-peer-deps

COPY . .

RUN npm run build -c configuration_island

# -----------------

FROM nginx:1.17.1-alpine
COPY --from=build /app/dist/login-demo /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
24 changes: 24 additions & 0 deletions webapp-ng/Dockerfile-webapp-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Build stage
FROM node:20.11-alpine3.19 AS build

RUN apk update && apk add git

RUN mkdir -p /app

WORKDIR /app

COPY package.json .
COPY package-lock.json .

RUN npm install --legacy-peer-deps

COPY . .

RUN npm run build -c configuration_prod

# -----------------

FROM nginx:1.17.1-alpine
COPY --from=build /app/dist/login-demo /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
24 changes: 24 additions & 0 deletions webapp-ng/Dockerfile-webapp-stage
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Build stage
FROM node:20.11-alpine3.19 AS build

RUN apk update && apk add git

RUN mkdir -p /app

WORKDIR /app

COPY package.json .
COPY package-lock.json .

RUN npm install --legacy-peer-deps

COPY . .

RUN npm run build -c configuration_stage

# -----------------

FROM nginx:1.17.1-alpine
COPY --from=build /app/dist/login-demo /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
94 changes: 91 additions & 3 deletions webapp-ng/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"namedChunks": true
},
"configurations": {
"production": {
"configuration_prod": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
Expand All @@ -61,7 +61,86 @@
"maximumWarning": "6kb"
}
]
},
"configuration_dev": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
},
"configuration_stage": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.stage.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
},
"configuration_island": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.island.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
}

},
"defaultConfiguration": ""
},
Expand All @@ -71,8 +150,17 @@
"buildTarget": "login-demo:build"
},
"configurations": {
"production": {
"buildTarget": "login-demo:build:production"
"configuration_prod": {
"buildTarget": "login-demo:build:configuration_prod"
},
"configuration_dev": {
"buildTarget": "login-demo:build:configuration_dev"
},
"configuration_stage": {
"buildTarget": "login-demo:build:configuration_stage"
},
"configuration_island": {
"buildTarget": "login-demo:build:configuration_island"
}
}
},
Expand Down
44 changes: 44 additions & 0 deletions webapp-ng/src/environments/environment.dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import config from '../../auth_config.json';

const { domain, clientId, authorizationParams: { audience }, apiUri, errorPath } = config as {
domain: string;
clientId: string;
authorizationParams: {
audience?: string;
},
apiUri: string;
errorPath: string;
};

export const environment = {
production: true,
auth: {
domain,
clientId,
authorizationParams: {
audience: `${audience}`,
redirect_uri: window.location.origin,
},
errorPath,
},
apiUri: `${apiUri}`,
httpInterceptor: {
allowedList: [
{
// uri: `${config.apiUri}/api/*`,
// uri: `${apiUri}/api/*`,
// uri: '/api/*',
uri: 'https://vcell-dev.cam.uchc.edu/api/*',

// allowAnonymous: true,
tokenOptions: {
authorizationParams: {
audience: `${audience}`,
scope: 'openid profile email'
}
}
},
],

},
};
44 changes: 44 additions & 0 deletions webapp-ng/src/environments/environment.island.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import config from '../../auth_config.json';

const { domain, clientId, authorizationParams: { audience }, apiUri, errorPath } = config as {
domain: string;
clientId: string;
authorizationParams: {
audience?: string;
},
apiUri: string;
errorPath: string;
};

export const environment = {
production: true,
auth: {
domain,
clientId,
authorizationParams: {
audience: `${audience}`,
redirect_uri: window.location.origin,
},
errorPath,
},
apiUri: `${apiUri}`,
httpInterceptor: {
allowedList: [
{
// uri: `${config.apiUri}/api/*`,
// uri: `${apiUri}/api/*`,
// uri: '/api/*',
uri: 'https://minikube-island/api/*',

// allowAnonymous: true,
tokenOptions: {
authorizationParams: {
audience: `${audience}`,
scope: 'openid profile email'
}
}
},
],

},
};
2 changes: 1 addition & 1 deletion webapp-ng/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const environment = {
// uri: `${config.apiUri}/api/*`,
// uri: `${apiUri}/api/*`,
// uri: '/api/*',
uri: 'https://vcell-stage.cam.uchc.edu/api/*',
uri: 'https://vcell.cam.uchc.edu/api/*',

// allowAnonymous: true,
tokenOptions: {
Expand Down
44 changes: 44 additions & 0 deletions webapp-ng/src/environments/environment.stage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import config from '../../auth_config.json';

const { domain, clientId, authorizationParams: { audience }, apiUri, errorPath } = config as {
domain: string;
clientId: string;
authorizationParams: {
audience?: string;
},
apiUri: string;
errorPath: string;
};

export const environment = {
production: true,
auth: {
domain,
clientId,
authorizationParams: {
audience: `${audience}`,
redirect_uri: window.location.origin,
},
errorPath,
},
apiUri: `${apiUri}`,
httpInterceptor: {
allowedList: [
{
// uri: `${config.apiUri}/api/*`,
// uri: `${apiUri}/api/*`,
// uri: '/api/*',
uri: 'https://vcell-stage.cam.uchc.edu/api/*',

// allowAnonymous: true,
tokenOptions: {
authorizationParams: {
audience: `${audience}`,
scope: 'openid profile email'
}
}
},
],

},
};
2 changes: 1 addition & 1 deletion webapp-ng/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const environment = {
// uri: `${config.apiUri}/api/*`,
// uri: `${apiUri}/api/*`,
// uri: '/api/*',
uri: 'https://vcell-stage.cam.uchc.edu/api/*',
uri: 'https://minikube-island/api/*',

// allowAnonymous: true,
tokenOptions: {
Expand Down

0 comments on commit 694aa15

Please sign in to comment.