Skip to content

Commit

Permalink
Merge pull request #4 from bcgov/test
Browse files Browse the repository at this point in the history
PROD deployment
  • Loading branch information
npham49 authored Nov 28, 2024
2 parents b087461 + a89d177 commit f5aa6af
Show file tree
Hide file tree
Showing 45 changed files with 830 additions and 333 deletions.
2 changes: 2 additions & 0 deletions client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
**/dist
43 changes: 9 additions & 34 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,13 @@
# Stage 1: Build the application
FROM node:lts-alpine AS builder

# Set the working directory inside the container
FROM node:latest as build-stage
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 install
COPY ./ .
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"]
FROM nginxinc/nginx-unprivileged:stable-alpine as production-stage
ENV NODE_ENV production
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 5173:5173
CMD ["nginx", "-g", "daemon off;"]
5 changes: 3 additions & 2 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/assets/images/bc_logo.svg" />
<link rel="icon" type="image/png" href="static/images/favicon.ico" />
<link rel="icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MEDIS Data Template Generator</title>
</head>
Expand Down
35 changes: 35 additions & 0 deletions client/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
server {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always
# connect via HTTPS (do not use if only testing)
add_header Strict-Transport-Security "max-age=31536000;";

# Enable cross-site filter (XSS) and tell browser to block detected attacks
add_header X-XSS-Protection "1; mode=block";

# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
add_header X-Content-Type-Options "nosniff";

# Disallow the site to be rendered within a frame (clickjacking protection)
add_header X-Frame-Options "DENY";

# Turn off all caddy caching
add_header Cache-Control "no-cache,no-store,must-revalidate";
add_header Pragma "no-cache";
listen 5173;
server_name localhost;
location / {
root /usr/share/nginx/html;
include /etc/nginx/mime.types;
index index.html;
try_files $uri $uri/ /index.html;
}
location ~* /favicon\.ico$ {
root /usr/share/nginx/html;
try_files /favicon.ico =404;
}
error_page 500 502 503 504 /50x.html;
location @index {
expires 0;
try_files /index.html =404;
}
}
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added client/public/favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import Header from "./components/bcgov/Header.vue";
import Nav from "./components/bcgov/Navbar.vue";
import { Toaster } from "vue-sonner";
import { computed, provide, ref } from "vue";
import { useDialogStore } from "./stores/appStore";
import { useAuthStore } from "./stores/authStore";
const isWideLayout = ref(false);
const dialogStore = useDialogStore();
const authStore = useAuthStore();
const appTitle = computed(() => {
return import.meta.env.VITE_TITLE;
});
Expand Down Expand Up @@ -34,6 +39,23 @@ defineExpose({
<Toaster richColors position="top-center" />
<Header :app-title="appTitle" />
<Nav />
<!-- Timed out dialog to log user back in -->
<v-dialog v-model="dialogStore.$state.isOpen" max-width="400" persistent>
<v-card :text="dialogStore.$state.message" :title="dialogStore.$state.title">
<template v-slot:actions>
<v-spacer></v-spacer>
<v-btn @click="authStore.logout()"> Logout </v-btn>
<v-btn
@click="
authStore.refreshUserToken();
dialogStore.closeDialog();
"
>
Confirm
</v-btn>
</template>
</v-card>
</v-dialog>
<!-- center the content in v-row -->
<!-- <div class="container mx-auto my-4"> -->
<div>
Expand Down
1 change: 1 addition & 0 deletions client/src/assets/bc_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f5aa6af

Please sign in to comment.