diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3fba21c0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +Dockerfile +docker-compose.yaml + +titledb/ +titles/ + +keys.txt +prod.keys +gdrive.token +token.pickle +credentials.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0d9a187a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM python:3.9 + +RUN apt-get update && apt-get install -y libusb-1.0-0-dev python3-pyqt5 libssl-dev libcurl4-openssl-dev + +WORKDIR /app + +COPY requirements.txt ./ + +RUN pip install -r requirements.txt + +COPY . ./ + +ARG USER=nut +ARG GROUP=nut +RUN addgroup --gid 1000 $USER && \ + adduser --uid 1000 --ingroup $GROUP --home /home/$USER --shell /bin/sh --disabled-password --gecos "" $USER && \ + curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.5.1/fixuid-0.5.1-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - && \ + chown root:root /usr/local/bin/fixuid && \ + chmod 4755 /usr/local/bin/fixuid && \ + mkdir -p /etc/fixuid && \ + printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml + +USER $USER:$GROUP + +ENTRYPOINT ["fixuid"] + +CMD ["python", "/app/nut_gui.py"] diff --git a/README.md b/README.md index 839f997e..5cb90d73 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,13 @@ PYCURL_SSL_LIBRARY=openssl LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/u * Run `python nut.py` for CLI. Run `python3 nut_gui.py` to launch the application (this will *only* work if PyQT from Homebrew was succesfully installed via directions above) +### Docker + +```console +$ docker build --tag nut https://github.com/blawar/nut.git +$ docker run --rm -it --network=host --env=DISPLAY --volume=/tmp/.X11-unix:/tmp/.X11-unix --volume="$PWD:$PWD" --workdir="$PWD" --user=$(id -u):$(id -g) nut +``` + ------ ## License