Merge branch 'github-actions/deployment' into chore/github-actions
This commit is contained in:
commit
b13b9dc674
107 changed files with 5474 additions and 602 deletions
36
frontend/Dockerfile
Normal file
36
frontend/Dockerfile
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
FROM node:22 AS build-stage
|
||||
|
||||
# install simple http server for serving static content
|
||||
RUN npm install -g http-server
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
|
||||
COPY package*.json ./
|
||||
COPY ./frontend/package.json ./frontend/
|
||||
|
||||
RUN npm install --silent
|
||||
|
||||
# Build the frontend
|
||||
|
||||
# Root tsconfig.json
|
||||
COPY tsconfig.json ./
|
||||
COPY assets ./assets/
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
COPY frontend ./
|
||||
|
||||
RUN npx vite build
|
||||
|
||||
FROM nginx:stable AS production-stage
|
||||
|
||||
COPY config/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
COPY --from=build-stage /app/assets /usr/share/nginx/html/assets
|
||||
COPY --from=build-stage /app/frontend/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dwengo-1-frontend",
|
||||
"version": "0.0.1",
|
||||
"version": "0.1.1",
|
||||
"description": "Frontend for Dwengo-1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.5.13",
|
||||
"vue-i18n": "^11.1.2",
|
||||
"vue-router": "^4.5.0",
|
||||
"vuetify": "^3.7.12",
|
||||
"oidc-client-ts": "^3.1.0",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
export const apiConfig = {
|
||||
baseUrl: window.location.hostname == "localhost" ? "http://localhost:3000" : window.location.origin,
|
||||
baseUrl:
|
||||
window.location.hostname === "localhost" && !(window.location.port === "80" || window.location.port === "")
|
||||
? "http://localhost:3000/api"
|
||||
: window.location.origin + "/api",
|
||||
};
|
||||
|
||||
export const loginRoute = "/login";
|
||||
|
|
|
|||
|
|
@ -12,12 +12,13 @@ import apiClient from "@/services/api-client.ts";
|
|||
import router from "@/router";
|
||||
import type { AxiosError } from "axios";
|
||||
|
||||
const authConfig = await loadAuthConfig();
|
||||
|
||||
const userManagers: UserManagersForRoles = {
|
||||
student: new UserManager(authConfig.student),
|
||||
teacher: new UserManager(authConfig.teacher),
|
||||
};
|
||||
async function getUserManagers(): Promise<UserManagersForRoles> {
|
||||
const authConfig = await loadAuthConfig();
|
||||
return {
|
||||
student: new UserManager(authConfig.student),
|
||||
teacher: new UserManager(authConfig.teacher),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the information about who is currently logged in from the IDP.
|
||||
|
|
@ -27,7 +28,7 @@ async function loadUser(): Promise<User | null> {
|
|||
if (!activeRole) {
|
||||
return null;
|
||||
}
|
||||
const user = await userManagers[activeRole].getUser();
|
||||
const user = await (await getUserManagers())[activeRole].getUser();
|
||||
authState.user = user;
|
||||
authState.accessToken = user?.access_token || null;
|
||||
authState.activeRole = activeRole || null;
|
||||
|
|
@ -59,7 +60,7 @@ async function initiateLogin() {
|
|||
async function loginAs(role: Role): Promise<void> {
|
||||
// Storing it in local storage so that it won't be lost when redirecting outside of the app.
|
||||
authStorage.setActiveRole(role);
|
||||
await userManagers[role].signinRedirect();
|
||||
await (await getUserManagers())[role].signinRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +71,7 @@ async function handleLoginCallback(): Promise<void> {
|
|||
if (!activeRole) {
|
||||
throw new Error("Login callback received, but the user is not logging in!");
|
||||
}
|
||||
authState.user = (await userManagers[activeRole].signinCallback()) || null;
|
||||
authState.user = (await (await getUserManagers())[activeRole].signinCallback()) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +85,7 @@ async function renewToken() {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
return await userManagers[activeRole].signinSilent();
|
||||
return await (await getUserManagers())[activeRole].signinSilent();
|
||||
} catch (error) {
|
||||
console.log("Can't renew the token:");
|
||||
console.log(error);
|
||||
|
|
@ -98,7 +99,7 @@ async function renewToken() {
|
|||
async function logout(): Promise<void> {
|
||||
const activeRole = authStorage.getActiveRole();
|
||||
if (activeRole) {
|
||||
await userManagers[activeRole].signoutRedirect();
|
||||
await (await getUserManagers())[activeRole].signoutRedirect();
|
||||
authStorage.deleteActiveRole();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue