Skip to content

Commit

Permalink
Add ability to run in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
ifel committed Jul 29, 2023
1 parent 84843fb commit 977eeb3
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 46 deletions.
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:20-alpine as build

WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY .babelrc .eslintrc nodemon.json package-lock.json package.json README.md ./
COPY build ./build/
COPY client ./client/
COPY server ./server/

RUN apk add zip
RUN npm install --omit=dev
RUN npm run build:client
RUN node build/prepkg.js linux
RUN pkg -t node18-linux-x64 -C GZip --options max-old-space-size=4096,expose-gc -o dist/linux/inpx-web .

# Build the prod image
FROM alpine:latest

# Move to /dist directory as the place for resulting binary folder
WORKDIR /app
RUN apk add libgcc libstdc++ gcompat
RUN mkdir -m 0777 data
COPY docker_entrypoint.sh entrypoint.sh
COPY --from=build /app/dist/linux/inpx-web .

EXPOSE 12380

HEALTHCHECK CMD curl --fail http://localhost:12380 || exit 1

ENTRYPOINT [ "/app/entrypoint.sh" ]
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ OPDS-сервер доступен по адресу [http://127.0.0.1:12380/opd

[Отблагодарить автора проекта](https://donatty.com/liberama)

##
##
* [Возможности программы](#capabilities)
* [Использование](#usage)
Expand All @@ -32,6 +33,7 @@ OPDS-сервер доступен по адресу [http://127.0.0.1:12380/opd
* [Сборка релизов](#build)
* [Запуск без сборки релиза](#native_run)
* [Разработка](#development)
* [Запуск в docker](#docker)

<a id="capabilities" />

Expand Down Expand Up @@ -369,4 +371,22 @@ node server --app-dir=.inpx-web
npm run dev
```

<a id="docker" />

### Запуск в docker

Сборка:
```sh
docker build -t inpx-web .
```

Запуск:
```sh
docker run -v /path/to/library:/library:ro --user=1000 -p 12380:12380 inpx-web
```

- В этом случае база данных и конфигурация будут пересоздаваться при каждом запуске. Для того, что сделать конфигурацию персистентной примонтируйте каталог в /app/data добавлением параметра в docker run: `-v /path/to/app_data:/app_data`
- Использование индекса, находящегося не в директории с библиотекой - передайте в docker run: `-v /path/to/index/flibusta.inpx:/app/index.inpx:ro -e INDEX_FILE=/app/index.inpx`
- Если используется персистентная конфигурация (см выше), но нужно перечитывать индекс при каждом запуске передайте в docker run: `-e RECREATE=1`

Связаться с автором проекта: [bookpauk@gmail.com](mailto:bookpauk@gmail.com)
11 changes: 11 additions & 0 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

OPTS="--lib-dir=/library --app-dir=/app/data"

[ -z ${INDEX_FILE+x} ] || OPTS="$OPTS --inpx=\"${INDEX_FILE}\""
[ -z ${RECREATE+x} ] || OPTS="$OPTS --recreate"

echo Starting ./inpx-web $OPTS
./inpx-web $OPTS
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,62 @@
"build:client-dev": "webpack --config build/webpack.dev.config.js",
"build:all": "npm run build:linux && npm run build:win && npm run build:macos && npm run build:linux-arm64",
"release": "npm run build:all && node build/release.js",
"postinstall": "npm run build:client-dev"
"postinstall": "npm run build:client"
},
"bin": "server/index.js",
"pkg": {
"scripts": "server/config/*.js",
"assets": "dist/public.json"
},
"devDependencies": {
},
"dependencies": {
"@babel/core": "^7.20.5",
"@babel/eslint-parser": "^7.19.1",
"@babel/eslint-plugin": "^7.19.1",
"@babel/plugin-proposal-decorators": "^7.20.5",
"@babel/preset-env": "^7.20.2",
"@quasar/extras": "^1.15.6",
"@vue/compiler-sfc": "^3.2.22",
"axios": "^0.27.2",
"babel-loader": "^9.1.0",
"chardet": "^1.5.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.2",
"css-minimizer-webpack-plugin": "^4.2.2",
"eslint": "^8.28.0",
"eslint-plugin-vue": "^9.8.0",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.7.1",
"pkg": "^5.8.0",
"showdown": "^2.1.0",
"terser-webpack-plugin": "^5.3.6",
"vue-eslint-parser": "^9.1.0",
"vue-loader": "^17.0.1",
"vue-style-loader": "^4.1.3",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-middleware": "^6.0.1",
"webpack-hot-middleware": "^2.25.3",
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@quasar/extras": "^1.15.6",
"axios": "^0.27.2",
"chardet": "^1.5.0",
"dayjs": "^1.11.6",
"express": "^4.18.2",
"express-basic-auth": "^1.2.1",
"eslint": "^8.28.0",
"eslint-plugin-vue": "^9.8.0",
"fs-extra": "^10.1.0",
"he": "^1.2.0",
"html-webpack-plugin": "^5.5.0",
"iconv-lite": "^0.6.3",
"jembadb": "^5.1.7",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
"mini-css-extract-plugin": "^2.7.1",
"minimist": "^1.2.7",
"node-stream-zip": "^1.15.0",
"pkg": "^5.8.0",
"quasar": "^2.10.2",
"safe-buffer": "^5.2.1",
"showdown": "^2.1.0",
"terser-webpack-plugin": "^5.3.6",
"vue": "^3.2.37",
"vue-loader": "^17.0.1",
"vue-router": "^4.1.6",
"vuex": "^4.1.0",
"vue-eslint-parser": "^9.1.0",
"vuex-persist": "^3.1.3",
"vue-style-loader": "^4.1.3",
"ws": "^8.11.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0",
"webpack-dev-middleware": "^6.0.1",
"webpack-hot-middleware": "^2.25.3",
"webpack-merge": "^5.8.0",
"yazl": "^2.5.1"
}
}

0 comments on commit 977eeb3

Please sign in to comment.