Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip #1

Merged
merged 27 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
louislam committed Nov 10, 2023
commit a12c6dc0339ecdd5350ca8f0e6948becc0e48ef7
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
node_modules
.idea
data
stacks
tmp
/private

Expand All @@ -11,5 +12,6 @@ docker
frontend
.editorconfig
.eslintrc.cjs
.git
.gitignore
README.md
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Should update .dockerignore as well
.env
node_modules
dist
frontend-dist
.idea
data
stacks
tmp
/private

# Git only
frontend-dist

15 changes: 14 additions & 1 deletion backend/dockge-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export class DockgeServer {
// Log NODE ENV
log.info("server", "NODE_ENV: " + process.env.NODE_ENV);

// Default stacks directory
let defaultStacksDir;
if (process.platform === "win32") {
defaultStacksDir = "./stacks";
} else {
defaultStacksDir = "/opt/stacks";
}

// Define all possible arguments
let args = parse<Arguments>({
sslKey: {
Expand All @@ -106,6 +114,10 @@ export class DockgeServer {
dataDir: {
type: String,
optional: true,
},
stacksDir: {
type: String,
optional: true,
}
});

Expand All @@ -118,6 +130,8 @@ export class DockgeServer {
this.config.port = args.port || parseInt(process.env.DOCKGE_PORT) || 5001;
this.config.hostname = args.hostname || process.env.DOCKGE_HOSTNAME || undefined;
this.config.dataDir = args.dataDir || process.env.DOCKGE_DATA_DIR || "./data/";
this.config.stacksDir = args.stacksDir || process.env.DOCKGE_STACKS_DIR || defaultStacksDir;
this.stacksDir = this.config.stacksDir;

log.debug("server", this.config);

Expand Down Expand Up @@ -406,7 +420,6 @@ export class DockgeServer {
}

// Create data/stacks directory
this.stacksDir = path.join(this.config.dataDir, "stacks");
if (!fs.existsSync(this.stacksDir)) {
fs.mkdirSync(this.stacksDir, { recursive: true });
}
Expand Down
6 changes: 1 addition & 5 deletions backend/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ export class Stack {
}

get isManagedByDockge() : boolean {
if (this._configFilePath) {
return this._configFilePath.startsWith(this.server.stackDirFullPath) && fs.existsSync(this.path) && fs.statSync(this.path).isDirectory();
} else {
return false;
}
return fs.existsSync(this.path) && fs.statSync(this.path).isDirectory();
}

get status() : number {
Expand Down
2 changes: 2 additions & 0 deletions backend/util-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ export interface Arguments {
port? : number;
hostname? : string;
dataDir? : string;
stacksDir? : string;
}

// Some config values are required
export interface Config extends Arguments {
dataDir : string;
stacksDir : string;
}

export function checkLogin(socket : DockgeSocket) {
Expand Down
6 changes: 4 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# 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
- ./data:/app/data
- /opt/stacks:/opt/stacks
environment:
- DOCKGE_STACKS_DIR=/opt/stacks
13 changes: 11 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
############################################
# Build
############################################
FROM louislam/dockge:base AS build
WORKDIR /app
COPY --chown=node:node ./package.json ./package.json
COPY --chown=node:node ./pnpm-lock.yaml ./pnpm-lock.yaml
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

############################################
# ⭐ Main Image
############################################
FROM louislam/dockge:base AS release
WORKDIR /app
COPY --chown=node:node . .
RUN pnpm install --prod --frozen-lockfile && \
mkdir ./data
COPY --from=build /app/node_modules /app/node_modules
RUN mkdir ./data

VOLUME /app/data
EXPOSE 5001
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Compose.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const template = `version: "3.8"
services:
nginx:
image: nginx:latest
restart: always
restart: unless-stopped
ports:
- "8080:80"
`;
Expand Down Expand Up @@ -538,7 +538,7 @@ export default {
}

this.jsonConfig.services[this.newContainerName] = {
restart: "always",
restart: "unless-stopped",
};
this.newContainerName = "";
let element = this.$refs.containerList.lastElementChild;
Expand Down
15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@
"type-fest": "~4.3.3",
"yaml": "~2.3.4"
},
"optionalDependencies": {
"pm2": "~5.3.0"
},
"devDependencies": {
"@fortawesome/fontawesome-svg-core": "6.4.2",
"@fortawesome/free-regular-svg-icons": "6.4.2",
"@fortawesome/free-solid-svg-icons": "6.4.2",
"@fortawesome/vue-fontawesome": "3.0.3",
"@types/bootstrap": "^5.2.8",
"@types/bootstrap": "~5.2.8",
"@types/command-exists": "~1.2.3",
"@types/express": "~4.17.21",
"@types/jsonwebtoken": "~9.0.4",
Expand All @@ -63,19 +60,17 @@
"eslint": "~8.50.0",
"eslint-plugin-jsdoc": "~46.8.2",
"eslint-plugin-vue": "~9.17.0",
"monaco-editor": "^0.44.0",
"monaco-yaml": "^5.1.0",
"prismjs": "~1.29.0",
"sass": "~1.68.0",
"typescript": "~5.2.2",
"unplugin-vue-components": "^0.25.2",
"unplugin-vue-components": "~0.25.2",
"vite": "~4.5.0",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-compression": "~0.5.1",
"vue": "~3.3.8",
"vue-eslint-parser": "^9.3.2",
"vue-eslint-parser": "~9.3.2",
"vue-i18n": "~9.5.0",
"vue-prism-editor": "2.0.0-alpha.2",
"vue-qrcode": "^2.2.0",
"vue-qrcode": "~2.2.0",
"vue-router": "~4.2.5",
"vue-toastification": "2.0.0-rc.5",
"xterm": "~5.3.0",
Expand Down
Loading