From 5cfccda801ba31008a9271e73bb1b368068ae15d Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Mon, 8 May 2023 16:39:16 -0300 Subject: [PATCH] Allow to run through docker --- .dockerignore | 11 +++++++++++ Dockerfile | 27 +++++++++++++++++++++++++++ README.md | 7 +++++++ 3 files changed, 45 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3fba21c04 --- /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 000000000..0d9a187a3 --- /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 839f997e3..5cb90d730 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