Skip to content

Commit 673b30f

Browse files
committed
make docker work
previously the dockerfile installed the dependencies and you then would mount the source folder into the container, shadowing the just created node_modules folder. So this setup only works if you had a node_modules folder on the host machine already which was kind of the reason to use docker in first place. To make this work, install the app into a subfolder and create the node_modules on folder up. Adopted some example files from here: - https://github.com/BretFisher/node-docker-good-defaults Also added a Makefile :-) So you can just do a 'make docker-server' or 'make docker-build'.
1 parent e1c336d commit 673b30f

File tree

8 files changed

+54
-46
lines changed

8 files changed

+54
-46
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# add git-ignore syntax here of things you don't want copied into docker image
2+
3+
.git
4+
*Dockerfile*
5+
*docker-compose*
6+
node_modules

.vitepress/config.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ export default defineConfig({
1515
// Can be removed as soon as the legacy content is removed
1616
srcExclude: ['**/legacy/**'],
1717

18+
vite: {
19+
server: {
20+
fs: {
21+
// Allow serving files from one level up to the project root
22+
allow: ['..', '../..'],
23+
},
24+
}
25+
},
26+
1827
themeConfig: {
1928

2029
logo: '/images/svg/naemonlogo.svg',
@@ -95,7 +104,7 @@ export default defineConfig({
95104
{ text: 'Plugins', link: '/documentation/usersguide/plugins' },
96105
{ text: 'Macros', link: '/documentation/usersguide/macros' },
97106
{ text: 'Standard Macros in Naemon', link: '/documentation/usersguide/macrolist' },
98-
107+
99108
{ text: 'Naemon Logo', link: '/logo' }
100109
]
101110
},

Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
# bash which makes debugging WAY easier
44
FROM node:22-bookworm
55

6-
RUN mkdir -p /site
6+
EXPOSE 5173
77

8-
WORKDIR /site
8+
RUN npm i npm@latest -g
99

10-
COPY package.json /site/package.json
10+
WORKDIR /opt/node_app
1111

12-
RUN npm install --verbose
12+
COPY package.json package-lock.json* ./
13+
RUN npm install --verbose --include=dev && npm cache clean --force
14+
ENV PATH /opt/node_app/node_modules/.bin:$PATH
1315

14-
EXPOSE 5173
16+
HEALTHCHECK --interval=30s CMD node healthcheck.js
17+
18+
WORKDIR /opt/node_app/app
19+
COPY . .
1520

1621
CMD ["npm", "run", "docs:dev"]

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/make -f
2+
3+
DOCKERRUN=docker run \
4+
--rm -it \
5+
-p 5173:5173 \
6+
--name=naemon-docs \
7+
-v `pwd`:/opt/node_app/app \
8+
-v /opt/node_app/node_modules/ \
9+
-v /opt/node_app/app/.vitepress/cache \
10+
-v /opt/node_app/app/.vitepress/dist \
11+
-v `pwd`/package.json:/opt/node_app/package.json \
12+
naemon/docs:latest
13+
14+
docker-build:
15+
docker build -t naemon/docs .
16+
$(DOCKERRUN) npm run docs:build
17+
18+
docker-server:
19+
docker build -t naemon/docs .
20+
$(DOCKERRUN)

legacy/Gemfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

legacy/Makefile

Lines changed: 0 additions & 33 deletions
This file was deleted.

legacy/favicon.ico

-1.12 KB
Binary file not shown.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{
2+
"name": "naemon-docs",
3+
"private": true,
4+
"version": "0.0.0",
25
"devDependencies": {
36
"vitepress": "^1.5.0"
47
},
58
"scripts": {
6-
"docs:dev": "vitepress dev --host",
7-
"docs:build": "vitepress build",
8-
"docs:preview": "vitepress preview"
9+
"docs:dev": "npx vitepress dev --host",
10+
"docs:build": "npx vitepress build",
11+
"docs:preview": "npx vitepress preview"
912
},
1013
"dependencies": {
1114
"@fortawesome/fontawesome-free": "^6.7.0"
1215
}
13-
}
16+
}
17+

0 commit comments

Comments
 (0)