From c2ec9ac7f43e02c13f81383c95d3bc6af9947f69 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 6 Nov 2023 22:54:20 +0800 Subject: [PATCH] wip --- .dockerignore | 2 -- README.md | 23 +++++++++++++++++++++-- backend/stack.ts | 2 +- backend/util-common.ts | 26 ++++++++++++++------------ compose.yaml | 10 ++++++++++ docker/Dockerfile | 5 +++-- docker/compose.yaml | 0 frontend/components.d.ts | 11 ----------- frontend/src/main.ts | 2 +- package.json | 2 +- 10 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 compose.yaml delete mode 100644 docker/compose.yaml diff --git a/.dockerignore b/.dockerignore index 4f85cc3..2e82244 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,6 @@ # Should be identical to .gitignore .env node_modules -dist -frontend-dist .idea data tmp diff --git a/README.md b/README.md index 099a21f..485c567 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,29 @@ A fancy, easy-to-use and reactive docker stack (`docker-compose.yml`) manager. - Interactive web terminal for containers and any docker commands - Reactive - Everything is just responsive. Progress and terminal output are in real-time - Easy-to-use & fancy UI - If you love Uptime Kuma's UI/UX, you will love this too -- Build on top of [Compose V2](https://docs.docker.com/compose/migrate/), as known as `compose.yaml` and `docker compose` - Convert `docker run ...` command into `docker-compose.yml` file -## Installation +## 🔧 How to Install + +1. Create a directory `./dockge/` +1. Create a `compose.yaml` inside `./dockge` file with the following content: + +```yaml +version: "3.8" +services: + dockge: + image: louislam/dockge:nightly + ports: + - 5001:5001 + volumes: + - ./data:/app/data + - /var/run/docker.sock:/var/run/docker.sock +``` + +2. `cd ./dockge/` +3. `docker-compose up -d` + +Dockge is now running on http://localhost:5001 ## Motivations diff --git a/backend/stack.ts b/backend/stack.ts index f8cb423..1944c3d 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -310,7 +310,7 @@ export class Stack { async joinCombinedTerminal(socket: DockgeSocket) { const terminalName = getCombinedTerminalName(this.name); - const terminal = Terminal.getOrCreateTerminal(this.server, terminalName, "docker", [ "compose", "logs", "-f" ], this.path); + const terminal = Terminal.getOrCreateTerminal(this.server, terminalName, "docker", [ "compose", "logs", "-f", "--tail", "100" ], this.path); terminal.rows = COMBINED_TERMINAL_ROWS; terminal.cols = COMBINED_TERMINAL_COLS; terminal.join(socket); diff --git a/backend/util-common.ts b/backend/util-common.ts index ec1eef5..278544f 100644 --- a/backend/util-common.ts +++ b/backend/util-common.ts @@ -1,6 +1,7 @@ /* * Common utilities for backend and frontend */ +import { Document } from "yaml"; // Init dayjs import dayjs from "dayjs"; @@ -11,20 +12,21 @@ dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(relativeTime); -import { parseDocument, Document } from "yaml"; - let randomBytes : (numBytes: number) => Uint8Array; +initRandomBytes(); -if (typeof window !== "undefined" && window.crypto) { - randomBytes = function randomBytes(numBytes: number) { - const bytes = new Uint8Array(numBytes); - for (let i = 0; i < numBytes; i += 65536) { - window.crypto.getRandomValues(bytes.subarray(i, i + Math.min(numBytes - i, 65536))); - } - return bytes; - }; -} else { - randomBytes = (await import("node:crypto")).randomBytes; +async function initRandomBytes() { + if (typeof window !== "undefined" && window.crypto) { + randomBytes = function randomBytes(numBytes: number) { + const bytes = new Uint8Array(numBytes); + for (let i = 0; i < numBytes; i += 65536) { + window.crypto.getRandomValues(bytes.subarray(i, i + Math.min(numBytes - i, 65536))); + } + return bytes; + }; + } else { + randomBytes = (await import("node:crypto")).randomBytes; + } } // Stack Status diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..d07b9fe --- /dev/null +++ b/compose.yaml @@ -0,0 +1,10 @@ +# docker run -d --name dockge -p 5001:5001 -v dockge:/app/data -v /var/run/docker.sock:/var/run/docker.sock --restart=always louislam/dockge:nightly +version: "3.8" +services: + dockge: + image: louislam/dockge:nightly + ports: + - 5001:5001 + volumes: + - ./data:/app/data + - /var/run/docker.sock:/var/run/docker.sock diff --git a/docker/Dockerfile b/docker/Dockerfile index 80505c7..1836b66 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,11 +1,12 @@ ############################################ # ⭐ Main Image ############################################ -FROM louislam/dockge:base +FROM louislam/dockge:base AS release WORKDIR /app COPY --chown=node:node . . RUN pnpm install --prod --frozen-lockfile && \ - mkdir ./data \ + mkdir ./data + VOLUME /app/data EXPOSE 5001 ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/docker/compose.yaml b/docker/compose.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/components.d.ts b/frontend/components.d.ts index 6fe98dc..f2e49e3 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -8,31 +8,20 @@ export {} declare module 'vue' { export interface GlobalComponents { About: typeof import('./src/components/settings/About.vue')['default'] - APIKeys: typeof import('./src/components/settings/APIKeys.vue')['default'] Appearance: typeof import('./src/components/settings/Appearance.vue')['default'] ArrayInput: typeof import('./src/components/ArrayInput.vue')['default'] - ArrayInputWithOptions: typeof import('./src/components/ArrayInputWithOptions.vue')['default'] - Backup: typeof import('./src/components/settings/Backup.vue')['default'] - BButton: typeof import('bootstrap-vue-next')['BButton'] BModal: typeof import('bootstrap-vue-next')['BModal'] Confirm: typeof import('./src/components/Confirm.vue')['default'] Container: typeof import('./src/components/Container.vue')['default'] - ContainerDialog: typeof import('./src/components/ContainerDialog.vue')['default'] - Docker: typeof import('./src/components/settings/Docker.vue')['default'] General: typeof import('./src/components/settings/General.vue')['default'] HiddenInput: typeof import('./src/components/HiddenInput.vue')['default'] Login: typeof import('./src/components/Login.vue')['default'] - MonitorHistory: typeof import('./src/components/settings/MonitorHistory.vue')['default'] NetworkInput: typeof import('./src/components/NetworkInput.vue')['default'] - Notifications: typeof import('./src/components/settings/Notifications.vue')['default'] - Proxies: typeof import('./src/components/settings/Proxies.vue')['default'] - ReverseProxy: typeof import('./src/components/settings/ReverseProxy.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] Security: typeof import('./src/components/settings/Security.vue')['default'] StackList: typeof import('./src/components/StackList.vue')['default'] StackListItem: typeof import('./src/components/StackListItem.vue')['default'] - Tags: typeof import('./src/components/settings/Tags.vue')['default'] Terminal: typeof import('./src/components/Terminal.vue')['default'] TwoFADialog: typeof import('./src/components/TwoFADialog.vue')['default'] Uptime: typeof import('./src/components/Uptime.vue')['default'] diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 1c8defd..662517c 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -1,5 +1,5 @@ // Dayjs init inside this, so it has to be the first import -await import("../../backend/util-common"); +import "../../backend/util-common"; import { createApp, defineComponent, h } from "vue"; import App from "./App.vue"; diff --git a/package.json b/package.json index eab18ee..638a775 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dev:backend": "cross-env NODE_ENV=development tsx watch ./backend/index.ts", "dev:frontend": "cross-env NODE_ENV=development vite --host --config ./frontend/vite.config.ts", "build:frontend": "vite build --config ./frontend/vite.config.ts", - "build:docker-base": "docker build -t louislam/dockge:base -f ./docker/Base.Dockerfile .", + "build:docker-base": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:base -f ./docker/Base.Dockerfile . --push", "build:docker": "pnpm run build:frontend && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:latest -f ./docker/Dockerfile . --push", "build:docker-nightly": "pnpm run build:frontend && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/dockge:nightly --target nightly -f ./docker/Dockerfile . --push", "start-docker": "docker run --rm -p 5001:5001 --name dockge louislam/dockge:latest",