mirror of
https://github.com/moghtech/komodo.git
synced 2026-02-14 16:18:59 -06:00
copy frontend into core for docker bundle
This commit is contained in:
1
core/.gitignore
vendored
Normal file
1
core/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
frontend
|
||||
@@ -3,6 +3,8 @@ FROM node:alpine
|
||||
RUN apk update && apk add docker git openrc --no-cache
|
||||
RUN addgroup root docker && rc-update add docker boot
|
||||
|
||||
COPY ./frontend /frontend
|
||||
|
||||
WORKDIR /monitor
|
||||
|
||||
COPY ./build/package.json ./
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "tsc && node build/main.js",
|
||||
"build": "vite build && node post-build.mjs && docker build -t mbecker2020/monitor-core .",
|
||||
"push": "yarn build && docker push mbecker2020/monitor-core",
|
||||
"docker-run": "docker run -d --name monitor-core --network=\"host\" -v /Users/max/GitHub/monitor/core/secrets:/secrets -v /Users/max/GitHub/monitor/frontend/build:/frontend mbecker2020/monitor-core",
|
||||
"docker-remove": "docker stop monitor-core && docker container rm monitor-core"
|
||||
"build-copy-frontend": "cd ../frontend && yarn build && cd ../core && rm -r frontend && mkdir frontend && cp -a ../frontend/build/. ./frontend/",
|
||||
"build": "vite build && node post-build.mjs && yarn build-copy-frontend && docker build -t mbecker2020/monitor-core .",
|
||||
"push": "yarn build && docker push mbecker2020/monitor-core"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@monitor/types": "1.0.0",
|
||||
|
||||
@@ -4,6 +4,7 @@ import styles from "./App.module.css";
|
||||
import UserInfo from "../UserInfo";
|
||||
import { User } from "@monitor/types"
|
||||
import Login from "../Login";
|
||||
import { AppStateProvider } from "../../state/StateProvider";
|
||||
|
||||
const App: Component = () => {
|
||||
const [user, { mutate }] = createResource(() => client.getUser());
|
||||
@@ -12,13 +13,15 @@ const App: Component = () => {
|
||||
<div class={styles.App}>
|
||||
<Switch>
|
||||
<Match when={user()}>
|
||||
<UserInfo
|
||||
user={user() as User}
|
||||
logout={() => {
|
||||
client.logout();
|
||||
mutate(false);
|
||||
}}
|
||||
/>
|
||||
<AppStateProvider>
|
||||
<UserInfo
|
||||
user={user() as User}
|
||||
logout={() => {
|
||||
client.logout();
|
||||
mutate(false);
|
||||
}}
|
||||
/>
|
||||
</AppStateProvider>
|
||||
</Match>
|
||||
<Match when={user() === undefined}>
|
||||
<div>...</div>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Component } from "solid-js";
|
||||
import { loginGithub } from "../util/helpers";
|
||||
import Input from "./util/Input";
|
||||
import Grid from "./util/layout/Grid";
|
||||
import { createStore } from "solid-js/store";
|
||||
@@ -59,7 +58,7 @@ const Login: Component<{ setUser: (user: User | false) => void }> = (p) => {
|
||||
<button onClick={login}>log in</button>
|
||||
<button onClick={signup}>sign up</button>
|
||||
</Flex>
|
||||
<button onClick={loginGithub}>log in with github</button>
|
||||
<button onClick={() => client.loginGithub()}>log in with github</button>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,15 +16,13 @@ export type State = {
|
||||
|
||||
const context = createContext<State & { ws: ReturnType<typeof useWs> }>();
|
||||
|
||||
export const Provider: Component<{}> = (p) => {
|
||||
export const AppStateProvider: Component<{}> = (p) => {
|
||||
const state: State = {
|
||||
servers: useServers(),
|
||||
builds: useBuilds(),
|
||||
deployments: useDeployments(),
|
||||
updates: useUpdates(),
|
||||
};
|
||||
|
||||
|
||||
// created state before attaching ws, to pass state easily to ws
|
||||
const ws = useWs(state);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import axios from "axios";
|
||||
import { URL } from "..";
|
||||
import { User } from "@monitor/types";
|
||||
|
||||
export default class Client {
|
||||
@@ -8,17 +7,14 @@ export default class Client {
|
||||
constructor(private baseURL: string) {
|
||||
const params = new URLSearchParams(location.search);
|
||||
const token = params.get("token");
|
||||
const redirect = params.get("redirect")
|
||||
if (token) {
|
||||
this.token = token;
|
||||
localStorage.setItem("access_token", this.token);
|
||||
history.replaceState(
|
||||
{},
|
||||
"",
|
||||
`${URL}${redirect ? `/?redirect=${redirect}` : ""}`
|
||||
this.baseURL
|
||||
);
|
||||
} else if (params.get("logout") === "true") {
|
||||
this.logout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +25,10 @@ export default class Client {
|
||||
return await this.getUser();
|
||||
}
|
||||
|
||||
loginGithub() {
|
||||
window.location.replace(`${this.baseURL}/login/github`);
|
||||
}
|
||||
|
||||
async signup(username: string, password: string) {
|
||||
const jwt: string = await this.post("/signup", { username, password });
|
||||
this.token = jwt;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { URL } from "..";
|
||||
import { Collection, User } from "@monitor/types";
|
||||
|
||||
export function combineClasses(...classes: (string | undefined)[]) {
|
||||
@@ -14,10 +13,6 @@ export function getAuthProvider(user: User) {
|
||||
else return "Local";
|
||||
}
|
||||
|
||||
export function loginGithub() {
|
||||
window.location.replace(`${URL}/login/github`);
|
||||
}
|
||||
|
||||
export function generateQuery(query?: Collection<string | number | undefined>) {
|
||||
if (query) {
|
||||
const q = Object.keys(query)
|
||||
|
||||
Reference in New Issue
Block a user