Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 37 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# lw.comm-server Docker Builds

This guide assumes some familiarity with [Docker](https://www.docker.com/), if you are new to Docker please start at: https://docs.docker.com/get-started/

Docker user targets:
- dev (default)

## Dev
You can build and run lw.comm-server in Docker using the commands below.
- build development image:
```
docker build -t lw.comm-server .
```
- run image:
```
docker run -it --device=/dev/ttyUSB0 --rm -p 8000:8000 --cap-add=sys_nice lw.comm-server
```
- Connect to app: http://localhost:8000

- Change the `--device=` to point to the correct USB device if necesscary, eg `--device=/dev/ttyACM0` etc.
- To use a different port change the port mapping in the `docker run` command to `<port number>:8000` and adjust the url you connect to appropriately.

## Run in background
If you add `-d` to the docker run command it will start the container in detached mode.
You can use `docker logs -f <uuid>` to follow the output of this, and `docker stop <uuid>` to stop it.

## Allow hot plugging & selection of connected devices
**This is NOT recommended, since it involves running the container in `--privileged` mode, which is a [potential security risk](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities).**

_..you have been warned.._

- run image:
```
docker run -it -v /dev:/dev --rm -p 8000:8000 --cap-add=sys_nice --privileged lw.comm-server
```
- when you connect the app you should be able to see all USB devices in the selection list

21 changes: 19 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
FROM resin/raspberrypi3-node:10
FROM node:16-bullseye AS base
#FROM resin/raspberrypi3-node:10

ADD config.js grblStrings.js firmwareFeatures.js LICENSE lw.comm-server.service package.json README.md server.js version.txt /laserweb/
ADD app /laserweb/app/

RUN cd /laserweb && npm install
# Set up Apt, install build tooling and udev
RUN apt update
RUN apt install -y build-essential udev

# Expose the port the container will serve on
EXPOSE 8000

FROM base AS comm-server

# Build lw.comm-server
RUN cd /laserweb && npm install

FROM comm-server AS dev

# Add the start script
ADD docker_entrypoint.sh /

# Entrypoint (defaulted)
ENTRYPOINT ["/docker_entrypoint.sh"]
CMD []

# Bash shell for debug
from comm-server as bash
ENTRYPOINT ["/bin/bash"]