add docker packaging

This commit is contained in:
ed 2023-02-10 23:02:01 +00:00
parent dbdb9574b1
commit 1526a4e084
12 changed files with 234 additions and 0 deletions

1
.gitignore vendored
View file

@ -25,6 +25,7 @@ copyparty.egg-info/
copyparty/res/COPYING.txt copyparty/res/COPYING.txt
copyparty/web/deps/ copyparty/web/deps/
srv/ srv/
scripts/docker/i/
contrib/package/arch/pkg/ contrib/package/arch/pkg/
contrib/package/arch/src/ contrib/package/arch/src/

View file

@ -110,6 +110,7 @@ download **[copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/
* or install through pypi (python3 only): `python3 -m pip install --user -U copyparty` * or install through pypi (python3 only): `python3 -m pip install --user -U copyparty`
* or if you cannot install python, you can use [copyparty.exe](#copypartyexe) instead * or if you cannot install python, you can use [copyparty.exe](#copypartyexe) instead
* or if you prefer to [use docker](./scripts/docker/) you can do that too 🐋
running the sfx without arguments (for example doubleclicking it on Windows) will give everyone read/write access to the current folder; you may want [accounts and volumes](#accounts-and-volumes) running the sfx without arguments (for example doubleclicking it on Windows) will give everyone read/write access to the current folder; you may want [accounts and volumes](#accounts-and-volumes)

View file

@ -57,6 +57,7 @@ hash -r
command -v python3 && pybin=python3 || pybin=python command -v python3 && pybin=python3 || pybin=python
} }
$pybin -c 'import numpy' ||
$pybin -m pip install --user numpy $pybin -m pip install --user numpy

View file

@ -232,6 +232,11 @@ rm x.py
cp -R /tmp/pe-copyparty.$(id -u)/copyparty/web/deps copyparty/web/ cp -R /tmp/pe-copyparty.$(id -u)/copyparty/web/deps copyparty/web/
``` ```
or you could build the web-dependencies from source instead (NB: does not include prismjs, need to grab that manually):
```sh
make -C scripts/deps-docker
```
then build the sfx using any of the following examples: then build the sfx using any of the following examples:
```sh ```sh

View file

@ -0,0 +1,14 @@
FROM alpine:latest
WORKDIR /z
RUN apk --no-cache add \
wget \
py3-pillow \
ffmpeg \
&& mkdir /cfg /w \
&& chmod 777 /cfg /w \
&& echo % /cfg > initcfg
COPY i/dist/copyparty-sfx.py ./
WORKDIR /w
ENTRYPOINT ["python3", "/z/copyparty-sfx.py", "-c", "/z/initcfg"]

View file

@ -0,0 +1,29 @@
FROM alpine:latest
WORKDIR /z
COPY i/bin/mtag/install-deps.sh ./
COPY i/bin/mtag/audio-bpm.py /mtag/
COPY i/bin/mtag/audio-key.py /mtag/
RUN apk add -U \
wget \
py3-pillow py3-pip \
ffmpeg \
vips-jxl vips-heif vips-poppler vips-magick \
py3-numpy fftw libsndfile \
&& python3 -m pip install pyvips \
&& apk --no-cache add -t .bd \
bash wget gcc g++ make cmake patchelf \
python3-dev ffmpeg-dev fftw-dev libsndfile-dev \
py3-wheel py3-numpy-dev \
&& bash install-deps.sh \
&& apk del py3-pip .bd \
&& rm -rf /var/cache/apk/* \
&& chmod 777 /root \
&& ln -s /root/vamp /root/.local / \
&& mkdir /cfg /w \
&& chmod 777 /cfg /w \
&& echo % /cfg > initcfg
COPY i/dist/copyparty-sfx.py ./
WORKDIR /w
ENTRYPOINT ["python3", "/z/copyparty-sfx.py", "-c", "/z/initcfg"]

View file

@ -0,0 +1,13 @@
FROM alpine:latest
WORKDIR /z
RUN apk --no-cache add \
wget \
py3-pillow \
&& mkdir /cfg /w \
&& chmod 777 /cfg /w \
&& echo % /cfg > initcfg
COPY i/dist/copyparty-sfx.py ./
WORKDIR /w
ENTRYPOINT ["python3", "/z/copyparty-sfx.py", "-c", "/z/initcfg"]

View file

@ -0,0 +1,17 @@
FROM alpine:latest
WORKDIR /z
RUN apk --no-cache add \
wget \
py3-pillow py3-pip \
ffmpeg \
vips-jxl vips-heif vips-poppler vips-magick \
&& python3 -m pip install pyvips \
&& apk del py3-pip \
&& mkdir /cfg /w \
&& chmod 777 /cfg /w \
&& echo % /cfg > initcfg
COPY i/dist/copyparty-sfx.py ./
WORKDIR /w
ENTRYPOINT ["python3", "/z/copyparty-sfx.py", "-c", "/z/initcfg"]

View file

@ -0,0 +1,12 @@
FROM alpine:latest
WORKDIR /z
RUN apk --no-cache add \
python3 \
&& mkdir /cfg /w \
&& chmod 777 /cfg /w \
&& echo % /cfg > initcfg
COPY i/dist/copyparty-sfx.py ./
WORKDIR /w
ENTRYPOINT ["python3", "/z/copyparty-sfx.py", "-c", "/z/initcfg"]

View file

@ -0,0 +1,12 @@
FROM alpine:latest
WORKDIR /z
RUN apk --no-cache add python3 py3-pip \
&& python3 -m pip install copyparty \
&& apk del py3-pip \
&& mkdir /cfg /w \
&& chmod 777 /cfg /w \
&& echo % /cfg > initcfg
WORKDIR /w
ENTRYPOINT ["python3", "-m", "copyparty", "-c", "/z/initcfg"]

55
scripts/docker/Makefile Normal file
View file

@ -0,0 +1,55 @@
self := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
all:
-service docker start
-systemctl start docker
rm -rf i
mkdir i
tar -cC../.. dist/copyparty-sfx.py bin/mtag | tar -xvCi
docker build -t copyparty/min:latest -f Dockerfile.min .
echo 'scale=1;'`docker save copyparty/min:latest | pigz -c | wc -c`/1024/1024 | bc
# docker build -t copyparty/min-pip:latest -f Dockerfile.min.pip .
# echo 'scale=1;'`docker save copyparty/min-pip:latest | pigz -c | wc -c`/1024/1024 | bc
docker build -t copyparty/im:latest -f Dockerfile.im .
echo 'scale=1;'`docker save copyparty/im:latest | pigz -c | wc -c`/1024/1024 | bc
docker build -t copyparty/iv:latest -f Dockerfile.iv .
echo 'scale=1;'`docker save copyparty/iv:latest | pigz -c | wc -c`/1024/1024 | bc
docker build -t copyparty/ac:latest -f Dockerfile.ac .
echo 'scale=1;'`docker save copyparty/ac:latest | pigz -c | wc -c`/1024/1024 | bc
docker build -t copyparty/dj:latest -f Dockerfile.dj .
echo 'scale=1;'`docker save copyparty/dj:latest | pigz -c | wc -c`/1024/1024 | bc
docker image ls
push:
docker push copyparty/min
docker push copyparty/im
docker push copyparty/iv
docker push copyparty/ac
docker push copyparty/dj
clean:
-docker kill `docker ps -q`
-docker rm `docker ps -qa`
-docker rmi `docker images -a | awk '/^<none>/{print$$3}'`
hclean:
-docker kill `docker ps -q`
-docker rm `docker ps -qa`
-docker rmi `docker images -a | awk '!/^alpine/&&NR>1{print$$3}'`
purge:
-docker kill `docker ps -q`
-docker rm `docker ps -qa`
-docker rmi `docker images -qa`
sh:
@printf "\n\033[1;31mopening a shell in the most recently created docker image\033[0m\n"
docker run --rm -it --entrypoint /bin/ash `docker images -aq | head -n 1`

74
scripts/docker/README.md Normal file
View file

@ -0,0 +1,74 @@
copyparty is availabe in these repos:
* https://hub.docker.com/r/copyparty
* https://github.com/9001?tab=packages&repo_name=copyparty
# getting started
run this command to grab the latest copyparty image and start it:
```bash
docker run --rm -it -u 1000 -p 3923:3923 -v /mnt/nas:/w -v $PWD/cfgdir:/cfg copyparty/ac
```
* `/w` is the path inside the container that gets shared by default, so mount one or more folders to share below there
* `/cfg` is an optional folder with zero or more config files (*.conf) to load
* `copyparty/ac` is the recommended [image edition](#editions)
* you can download the image from github instead by replacing `copyparty/ac` with TODO
i'm unfamiliar with docker-compose and alternatives so let me know if this section could be better 🙏
## configuration
the container has the same default config as the sfx and the pypi module, meaning it will listen on port 3923 and share the "current folder" (`/w` inside the container) as read-write for anyone
the recommended way to configure copyparty inside a container is to mount a folder which has one or more [config files](https://github.com/9001/copyparty/blob/hovudstraum/docs/example.conf) inside; `-v /your/config/folder:/cfg`
* but you can also provide arguments to the docker command if you prefer that
* config files must be named `something.conf` to get picked up
## editions
with image size after installation and when gzipped
* `min` (57 MiB, 20 gz) is just copyparty itself
* `im` (69 MiB, 24 gz) can create thumbnails using pillow (pics only)
* `ac` (163 MiB, 56 gz) is `im` plus ffmpeg for video/audio thumbnails + audio transcoding
* `iv` (211 MiB, 73 gz) is `ac` plus vips for faster heif / avic / jxl thumbnails
* `dj` (309 MiB, 104 gz) is `iv` plus beatroot/keyfinder to detect musical keys and bpm
`ac` is recommended since the additional features available in `iv` and `dj` are rarely useful
## detecting bpm and musical key
the `dj` edition comes with `keyfinder` and `beatroot` which can be used to detect music bpm and musical keys
enable them globally in a config file:
```yaml
[global]
e2dsa, e2ts # enable filesystem indexing and multimedia indexing
mtp: .bpm=f,t30,/mtag/audio-bpm.py # should take ~10sec
mtp: key=f,t190,/mtag/audio-key.py # should take ~50sec
```
or enable them for just one volume,
```yaml
[/music] # share name / URL
music # filesystem path inside the docker volume `/w`
flags:
e2dsa, e2ts
mtp: .bpm=f,t30,/mtag/audio-bpm.py
mtp: key=f,t190,/mtag/audio-key.py
```
or using commandline arguments,
```
-e2dsa -e2ts -mtp .bpm=f,t30,/mtag/audio-bpm.py -mtp key=f,t190,/mtag/audio-key.py
```
# build the images yourself
put `copyparty-sfx.py` into `../dist/` (or [build that from scratch](../docs/devnotes.md#just-the-sfx) too) then run `make`