Dockerize server

Adds a new argument and environment variable to change the SQLite
storage path, which helps with the Docker volume.

Adds a .gitignore for any docker-compose.override.yml files.
This commit is contained in:
Lim Ding Wen 2025-07-05 22:22:21 +08:00
parent 9698d200a0
commit 98912426a7
6 changed files with 60 additions and 2 deletions

3
.env.example Normal file
View file

@ -0,0 +1,3 @@
MIKUPAD_LOGIN="anon"
MIKUPAD_PASSWORD="SET_YOUR_PASSWORD_HERE"
MIKUPAD_STORAGE_PATH="/storage/web-session-storage.db"

5
.gitignore vendored
View file

@ -132,4 +132,7 @@ dist
.yarn/unplugged .yarn/unplugged
.yarn/build-state.yml .yarn/build-state.yml
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
# Docker Compose
docker-compose.override.yml

18
Dockerfile Normal file
View file

@ -0,0 +1,18 @@
FROM node:20.19.3
COPY project /app/project
COPY server /app/server
COPY mikupad.html /app/mikupad.html
COPY compile.sh /app/compile.sh
# Compile HTML
WORKDIR /app
RUN /bin/bash compile.sh
# Server expects mikupad.html
RUN mv /app/mikupad_compiled.html /app/mikupad.html
# Compile server
WORKDIR /app/server
RUN npm install --no-audit
ENTRYPOINT [ "node", "server.js" ]

View file

@ -36,6 +36,26 @@ To use **mikupad** fully offline, run the provided `compile` script or download
You can also [try it on GitHub Pages](https://lmg-anon.github.io/mikupad/mikupad.html). You can also [try it on GitHub Pages](https://lmg-anon.github.io/mikupad/mikupad.html).
## Running with Docker
You can also run **mikupad** using Docker. This automatically compiles the HTML and runs the custom NodeJS server, which serves the HTML, among other functions.
First, copy `.env.example` to `.env`. Then, **change your username and password**; anyone who has access to your hosted **mikupad** can store and load sessions, and proxy network requests through your server!
To run the server:
```shell
docker compose up --build -d
```
Then visit http://localhost:3000/.
Note that by default, the server will automatically start when Docker starts (which likely also starts on login). To stop the server, and at the same time also stop it from automatically starting up:
```shell
docker compose down
```
## Contributing ## Contributing
Contributions from the open-source community are welcome. Whether it's fixing a bug, adding a feature, or improving the documentation, your contributions are greatly appreciated. To contribute to **mikupad**, follow these steps: Contributions from the open-source community are welcome. Whether it's fixing a bug, adding a feature, or improving the documentation, your contributions are greatly appreciated. To contribute to **mikupad**, follow these steps:

13
docker-compose.yml Normal file
View file

@ -0,0 +1,13 @@
services:
mikupad:
build: .
ports:
- 3000:3000
env_file:
- .env
restart: unless-stopped
volumes:
- storage:/storage
volumes:
storage:

View file

@ -17,6 +17,7 @@ const host = args.host || process.env.MIKUPAD_HOST || '0.0.0.0';
const noOpen = (args.open !== undefined && !args.open) || process.env.MIKUPAD_NO_OPEN; const noOpen = (args.open !== undefined && !args.open) || process.env.MIKUPAD_NO_OPEN;
const login = args.login || process.env.MIKUPAD_LOGIN || 'anon'; const login = args.login || process.env.MIKUPAD_LOGIN || 'anon';
const password = args.password || process.env.MIKUPAD_PASSWORD || undefined; const password = args.password || process.env.MIKUPAD_PASSWORD || undefined;
const storagePath = args.storagePath || process.env.MIKUPAD_STORAGE_PATH || './web-session-storage.db';
// Headers that shouldn't be forwarded in the proxy endpoint. // Headers that shouldn't be forwarded in the proxy endpoint.
const headersToRemove = [ const headersToRemove = [
@ -54,7 +55,7 @@ app.use((req, res, next) => {
}); });
// Open a database connection // Open a database connection
const db = new sqlite3.Database('./web-session-storage.db', (err) => { const db = new sqlite3.Database(storagePath, (err) => {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
throw err; throw err;