Skip to content

Commit

Permalink
adding OS deployment artifacts and Dockerfile for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
npham49 committed Oct 31, 2024
1 parent b3a63d7 commit b087461
Show file tree
Hide file tree
Showing 10 changed files with 289 additions and 32 deletions.
38 changes: 38 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Stage 1: Build the application
FROM node:lts-alpine AS builder

# Set the working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install dependencies
RUN npm ci

# Copy the rest of the application code to the working directory
COPY . .

# Build the application
RUN npm run build

# Stage 2: Serve the application
FROM node:lts-alpine

# Install http-server globally to serve static files
RUN npm install -g http-server

# Set the working directory inside the container
WORKDIR /app

# Copy the built files from the previous stage
COPY --from=builder /app/dist ./dist

# Copy index.html to 404 to fix client side routing
COPY --from=builder /app/dist/index.html ./dist/404.html

# Expose port 5173 to the outside world
EXPOSE 5173

# Command to run http-server to serve the built files
CMD ["http-server", "dist", "-p", "5173", "--history-api-fallback"]
5 changes: 4 additions & 1 deletion client/src/components/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ const mutation = useMutation({
reportingPeriod: String(selectedPeriod.value),
})
.then((data) => {
FileSaver.saveAs(data.data, "output.xlsm");
FileSaver.saveAs(
data.data,
`${initiative.value}${selectedHealthAuthority.value}${selectedPeriod.value}.xlsm`
);
toast.success("Template downloaded successfully", {
duration: 5000,
});
Expand Down
1 change: 0 additions & 1 deletion client/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import GenerateTemplate from "./views/GenerateTemplate.vue";
import ReplaceTemplate from "./views/ReplaceTemplate.vue";
import NProgress from "nprogress";
import Home from "./views/Home.vue";
import KeycloakService from "./services/keycloak";
import { useAuthStore } from "./stores/authStore";
import NotAuthorized from "./views/NotAuthorized.vue";
import apiService from "./services/apiService";
Expand Down
14 changes: 1 addition & 13 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@ import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "node:path";

const proxyObject = {
target: "http://localhost:8080",
ws: true,
changeOrigin: true,
};

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
// base: "/app",
server: {
proxy: {
"/api": proxyObject,
"/config": proxyObject,
},
},
base: "/app",
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
Expand Down
169 changes: 169 additions & 0 deletions openshift/bc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
apiVersion: template.openshift.io/v1
kind: Template
metadata:
creationTimestamp: null
name: medis-data-template
labels:
template: medis-data-template
objects:
- apiVersion: v1
kind: ImageStream
metadata:
annotations:
name: ${NAME}
app.openshift.io/vcs-ref: ${SOURCE_REPOSITORY_REF}
app.openshift.io/vcs-uri: ${SOURCE_REPOSITORY_URL}
name: ${NAME}-backend
creationTimestamp: null
namespace: ${NAMESPACE}
labels:
shared: true
app: ${NAME}
app.kubernetes.io/component: ${NAME}
app.kubernetes.io/instance: ${NAME}
app.kubernetes.io/name: ${NAME}
app.openshift.io/runtime: nodejs
app.openshift.io/runtime-version: ${NODE_JS_VERSION}
spec:
lookupPolicy:
local: false
- apiVersion: v1
kind: ImageStream
metadata:
annotations:
name: ${NAME}
app.openshift.io/vcs-ref: ${SOURCE_REPOSITORY_REF}
app.openshift.io/vcs-uri: ${SOURCE_REPOSITORY_URL}
name: ${NAME}-frontend
creationTimestamp: null
namespace: ${NAMESPACE}
labels:
shared: true
app: ${NAME}
app.kubernetes.io/component: ${NAME}
app.kubernetes.io/instance: ${NAME}
app.kubernetes.io/name: ${NAME}
app.openshift.io/runtime: nodejs
app.openshift.io/runtime-version: ${NODE_JS_VERSION}
spec:
lookupPolicy:
local: false
- apiVersion: v1
kind: BuildConfig
metadata:
annotations:
name: ${NAME}
app.openshift.io/vcs-ref: ${SOURCE_REPOSITORY_REF}
app.openshift.io/vcs-uri: ${SOURCE_REPOSITORY_URL}
name: ${NAME}-backend
creationTimestamp: null
namespace: ${NAMESPACE}
labels:
app: ${NAME}
app.openshift.io/runtime: nodejs
spec:
nodeSelector: null
output:
to:
kind: ImageStreamTag
name: ${NAME}-backend:${TAG}
successfulBuildsHistoryLimit: 5
failedBuildsHistoryLimit: 5
strategy:
type: Docker
dockerStrategy:
dockerfilePath: Dockerfile
postCommit: {}
resources:
requests:
cpu: 500Mi
memory: 500Mi
limits:
cpu: 1
memory: 1Gi
source:
type: Git
git:
uri: ${SOURCE_REPOSITORY_URL}
ref: ${SOURCE_REPOSITORY_REF}
contextDir: /server
triggers:
- type: ConfigChange
- imageChange: {}
type: ImageChange
runPolicy: Serial
- apiVersion: v1
kind: BuildConfig
metadata:
annotations:
name: ${NAME}
app.openshift.io/vcs-ref: ${SOURCE_REPOSITORY_REF}
app.openshift.io/vcs-uri: ${SOURCE_REPOSITORY_URL}
name: ${NAME}-frontend
creationTimestamp: null
namespace: ${NAMESPACE}
labels:
app: ${NAME}
app.openshift.io/runtime: nodejs
spec:
nodeSelector: null
output:
to:
kind: ImageStreamTag
name: ${NAME}-frontend:${TAG}
successfulBuildsHistoryLimit: 5
failedBuildsHistoryLimit: 5
strategy:
type: Docker
dockerStrategy:
dockerfilePath: Dockerfile
postCommit: {}
resources:
requests:
cpu: 500Mi
memory: 500Mi
limits:
cpu: 1
memory: 1Gi
source:
type: Git
git:
uri: ${SOURCE_REPOSITORY_URL}
ref: ${SOURCE_REPOSITORY_REF}
contextDir: /client
triggers:
- type: ConfigChange
- imageChange: {}
type: ImageChange
runPolicy: Serial
parameters:
- description: A name used for all objects
displayName: Name
name: NAME
required: true
value: medis-data-template
- description: The namespace of the project namespace
displayName: Namespace
name: NAMESPACE
required: true
value: ""
- description: Tag used for the image tags
displayName: tag
name: TAG
required: true
value: latest
- description: SOURCE_REPOSITORY_URL
displayName: SOURCE_REPOSITORY_URL
name: SOURCE_REPOSITORY_URL
required: true
value: "https://github.com/bcgov/medis-data-template-generator"
- description: SOURCE_REPOSITORY_REF
displayName: SOURCE_REPOSITORY_REF
name: SOURCE_REPOSITORY_REF
required: true
value: dev
- description: NODE_JS_VERSION
displayName: NODE_JS_VERSION
name: NODE_JS_VERSION
required: true
value: "20"
13 changes: 13 additions & 0 deletions openshift/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: medis-data-template-frontend
data:
VITE_KEYCLOAK_URL:
VITE_KEYCLOAK_REALM:
VITE_KEYCLOAK_CLIENT_ID:
VITE_SSO_REDIRECT_URI:
VITE_BASE_PATH:
VITE_ENVIRONMENT:
VITE_API_URL:
NODE_ENV:
Empty file added openshift/dc.yaml
Empty file.
38 changes: 38 additions & 0 deletions openshift/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v1
kind: Secret
metadata:
name:
type: Opaque
stringData:
RLS_API_URL:
RLS_HA_FORM_ID:
RLS_ROLE_FORM_ID:
RLS_API_KEY:
TEMPLATE_ROUTE:
CHEFS_API_URL:
CHEFS_FISCAL_YEAR_REPORTING_DATES_FORM_ID:
CHEFS_FISCAL_YEAR_REPORTING_DATES_API_KEY:
CHEFS_PCN_BUDGET_FORM_ID:
CHEFS_PCN_BUDGET_API_KEY:
CHEFS_CHC_BUDGET_FORM_ID:
CHEFS_CHC_BUDGET_API_KEY:
CHEFS_UPCC_BUDGET_FORM_ID:
CHEFS_UPCC_BUDGET_API_KEY:
CHEFS_NPPCC_BUDGET_FORM_ID:
CHEFS_NPPCC_BUDGET_API_KEY:
CHEFS_PCN_FINANCIAL_FORM_ID:
CHEFS_PCN_FINANCIAL_API_KEY:
CHEFS_CHC_FINANCIAL_FORM_ID:
CHEFS_CHC_FINANCIAL_API_KEY:
CHEFS_UPCC_FINANCIAL_FORM_ID:
CHEFS_UPCC_FINANCIAL_API_KEY:
CHEFS_NPPCC_FINANCIAL_FORM_ID:
CHEFS_NPPCC_FINANCIAL_API_KEY:
MINIO_ENDPOINT:
MINIO_ACCESS_KEY:
MINIO_SECRET_KEY:
MINIO_BUCKET:
MINIO_REGION:
ENVIRONMENT:
PORT:
JWKS_URI:
33 changes: 16 additions & 17 deletions server/api/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export default {
proratedYtdBudget: "AB",
ytdExpenseVariance: "AC",
ftesHiredToDate: "AD",
ytdExpenseVarianceNote: "AE",
fyExpenseForecast: "AF",
fyEstimatedSurplus: "AG",
fyExpenseVariance: "AH",
fyExpenseForecast: "AE",
fyEstimatedSurplus: "AF",
fyExpenseVariance: "AG",
ytdExpenseVarianceNote: "AH",
fyExpenseVarianceNote: "AI",
additionalNotes: "AJ",
reasonForExceptionInPeriodReported: "AK",
Expand Down Expand Up @@ -72,10 +72,10 @@ export default {
proratedYtdBudget: "AG",
ytdExpenseVariance: "AH",
ftesHiredToDate: "AI",
ytdExpenseVarianceNote: "AJ",
fyExpenseForecast: "AK",
fyEstimatedSurplus: "AL",
fyExpenseVariance: "AM",
fyExpenseForecast: "AJ",
fyEstimatedSurplus: "AK",
fyExpenseVariance: "AL",
ytdExpenseVarianceNote: "AM",
fyExpenseVarianceNote: "AN",
notes: "AO",
reasonForExceptionInPeriodReported: "AP",
Expand Down Expand Up @@ -111,16 +111,15 @@ export default {
proratedYtdBudget: "AC",
ytdExpenseVariance: "AD",
ftesHiredToDate: "AE",
ytdExpenseVarianceNote: "AF",
fyExpenseForecast: "AG",
fyEstimatedSurplus: "AH",
fyExpenseVariance: "AI",
fyExpenseForecast: "AF",
fyEstimatedSurplus: "AG",
fyExpenseVariance: "AH",
ytdExpenseVarianceNote: "AI",
fyExpenseVarianceNote: "AJ",
additionalNotes: "AK",
reasonForExceptionInPeriodReported: "AL",
},
NPPCC: {
sheetId: 4,
fiscalYear: "B",
periodReported: "C",
healthAuthority: "D",
Expand Down Expand Up @@ -150,10 +149,10 @@ export default {
proratedYtdBudget: "AB",
ytdExpenseVariance: "AC",
ftesHiredToDate: "AD",
ytdExpenseVarianceNote: "AE",
fyExpenseForecast: "AF",
fyEstimatedSurplus: "AG",
fyExpenseVariance: "AH",
fyExpenseForecast: "AE",
fyEstimatedSurplus: "AF",
fyExpenseVariance: "AG",
ytdExpenseVarianceNote: "AH",
fyExpenseVarianceNote: "AI",
additionalNotes: "AJ",
reasonForExceptionInPeriodReported: "AK",
Expand Down
10 changes: 10 additions & 0 deletions server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ import * as middlewares from "./middlewares/common";
import { protectMiddleware } from "./middlewares/jwt";
import router from "./api/routes";
import { roleMiddleware } from "./middlewares/role";
import env from "./api/utils/env";

require("dotenv").config();

// ENVs check
Object.keys(env).forEach((key) => {
const envKey = key as keyof typeof env;
if (!env[envKey]) {
console.error(`ENV ${envKey} is missing`);
process.exit(1);
}
});

const corsOptions = {
origin:
process.env.ORIGIN_URL ||
Expand Down

0 comments on commit b087461

Please sign in to comment.