diff --git a/Dockerfile b/Dockerfile index 0ec22e8..7c72822 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ ### builder -FROM alpine:edge AS builder - -ARG SCRCPY_VER=1.16 -ARG SERVER_HASH="94a79e05b4498d0460ab7bd9d12cbf05156e3a47bf0c5d1420cee1d4493b3832" +FROM alpine:edge AS alpine-c-base-builder RUN apk add --no-cache \ + build-base \ curl \ ffmpeg-dev \ gcc \ git \ + libusb \ + libusb-dev \ make \ meson \ musl-dev \ @@ -16,6 +16,11 @@ RUN apk add --no-cache \ pkgconf \ sdl2-dev +FROM alpine-c-base-builder AS builder + +ARG SCRCPY_VER=v2.7 +ARG SERVER_HASH="0019dfc4b32d63c1392aa264aed2253c1e0c2fb09216f8e2cc269bbfb8bb49b5" + RUN PATH=$PATH:/usr/lib/jvm/java-1.8-openjdk/bin RUN curl -L -o scrcpy-server https://github.com/Genymobile/scrcpy/releases/download/v${SCRCPY_VER}/scrcpy-server-v${SCRCPY_VER} RUN echo "$SERVER_HASH /scrcpy-server" | sha256sum -c - @@ -26,30 +31,37 @@ RUN cd scrcpy/x && ninja ### runner FROM alpine:edge AS runner +LABEL maintainer="Pierre Gordon " + # needed for android-tools -RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories +RUN echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories -LABEL maintainer="Pierre Gordon " -RUN apk add --no-cache \ +RUN apk add -U --no-cache \ android-tools \ ffmpeg \ + libusb \ + libusb-dev \ virtualgl COPY --from=builder /scrcpy-server /usr/local/share/scrcpy/ COPY --from=builder /scrcpy/x/app/scrcpy /usr/local/bin/ -### runner (amd) -FROM runner AS amd +FROM runner AS gallium + +RUN apk add --no-cache mesa-dri-gallium + +#### runner (amd) +#FROM runner AS amd -RUN apk add --no-cache mesa-dri-swrast +##RUN apk add --no-cache mesa-dri-swrast -### runner (intel) -FROM runner AS intel +#### runner (intel) +#FROM runner AS intel -RUN apk add --no-cache mesa-dri-intel +#RUN apk add --no-cache mesa-dri-intel -### runner (nvidia) -FROM runner AS nvidia +#### runner (nvidia) +#FROM runner AS nvidia -RUN apk add --no-cache mesa-dri-nouveau +#RUN apk add --no-cache mesa-dri-nouveau diff --git a/README.md b/README.md index c72e535..868b8f4 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ Docker image to run [scrcpy](https://github.com/Genymobile/scrcpy). +## Build + +`sudo docker build -t scrcpy:latest .` + ## Usage Before running the image, Docker must be allowed to connect to the X server: @@ -30,7 +34,7 @@ For example: `pierlo1/scrcpy:amd`. To run the image with Docker run: ```shell -docker run --rm -i -t --privileged \ +sudo docker run --rm -i -t --privileged \ -v /dev/bus/usb:/dev/bus/usb \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e DISPLAY=$DISPLAY \ @@ -45,7 +49,7 @@ For persistence, make a copy of `.env.example`, name it `.env`, and configure it Once done, run the command: ```shell -docker-compose run --rm scrcpy +sudo docker-compose run --rm scrcpy ``` The `scrcpy_adb_keys` volume is used to preserve the `adb` authorization keys. diff --git a/docker-compose.yml b/docker-compose.yml index 17080aa..e5f0db2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.7' services: scrcpy: - image: pierlo1/scrcpy:${SCRCPY_GRAPHICS_TYPE:?Please set the SCRCPY_GRAPHICS_TYPE environment variable.} + image: scrcpy:${SCRCPY_GRAPHICS_TYPE:?Please set the SCRCPY_GRAPHICS_TYPE environment variable.} volumes: - /dev/bus/usb:/dev/bus/usb:ro - /tmp/.X11-unix:/tmp/.X11-unix:ro @@ -13,6 +13,7 @@ services: ADB_VENDOR_KEYS: /root/.android privileged: true tty: true + command: scrcpy --video-codec=h265 --max-size=1920 --max-fps=60 --no-audio --keyboard=uhid volumes: scrcpy_adb_keys: