logux
logux copied to clipboard
Docker docs
How to run Logux server in Docker with Dockerfile example
This is config for traefik. Add index.js, package.json to logux folder, than create docker-compose.yml:
version: "3.7"
networks:
web:
external: true
services:
loguxserver:
image: node:17-alpine
command: sh -c "npm install&&node index.js"
expose:
- 31337
labels:
- "traefik.enable=true"
- "traefik.http.routers.loguxhttps.entrypoints=https"
- "traefik.http.routers.loguxhttps.rule=Host(`mydomain.com`)"
- "traefik.http.routers.loguxhttps.tls=true"
- "traefik.http.routers.loguxhttps.tls.certresolver=letsEncrypt"
- "traefik.docker.network=web"
- "traefik.port=31337"
networks:
- web
environment:
LOGUX_BACKEND: http://localhost:3001/
LOGUX_CONTROL_SECRET: secret
LOGUX_CONTROL_MASK: 0.0.0.0/0
TZ: "Europe/Moscow"
working_dir: /app
volumes:
- ./logux/:/app
(Just a few thoughts so I don't forget.)
We already have a basic recipe for Dockerfile: https://github.com/logux/docs/blob/main/recipes/deployment.md.
But I think it is not enough for a beginners. We need to add:
- [ ] Example of using Logux inside Docker Compose
- [ ] Example of using Logux inside a pnpm workspace with
pnpm fetch.
FROM node:20
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
WORKDIR /project
COPY pnpm-lock.yaml ./
RUN pnpm fetch
ADD . ./
RUN pnpm install -r --offline
- [ ] Example of using a health check
healthcheck:
test: "curl -f http://localhost:${LOGUX_PORT}/health || exit 1"
interval: 10s
timeout: 5s
retries: 5
- [ ] Note that environment variables with the
LOGUX_prefix are reserved - [ ] How to use
LOGUX_CONTROL_MASKenvironment variable with Docker Compose Network
DOCKER_NETWORK_SUBNET=172.28.0.0/16
DOCKER_NETWORK_GATEWAY=172.28.0.1
LOGUX_CONTROL_MASK=172.28.0.0/16
networks:
default:
ipam:
driver: default
config:
- subnet: ${DOCKER_NETWORK_SUBNET}
gateway: ${DOCKER_NETWORK_GATEWAY}