Added Dockerfile and ws-scrcpy startup script#150
Added Dockerfile and ws-scrcpy startup script#150vitalyrepin wants to merge 1 commit intoNetrisTV:masterfrom
Conversation
drauggres
left a comment
There was a problem hiding this comment.
Hi. Thank you for your contribution.
It works, but there are some improvements that could be done. With all the changes I suggest Dockerfile looks like this (assuming it will be moved to the projects root):
FROM alpine:3.14 AS builder
ADD . /ws-scrcpy
RUN apk add --no-cache nodejs npm python3 make g++
WORKDIR /ws-scrcpy
RUN npm install
RUN npm run dist
WORKDIR dist
RUN npm install
FROM alpine:3.14 AS runner
LABEL maintainer="Vitaly Repin <vitaly.repin@gmail.com>"
RUN apk add --no-cache android-tools npm
COPY --from=builder /ws-scrcpy/dist /root/ws-scrcpy
WORKDIR /root/ws-scrcpy
CMD ["npm", "start"]But if you don't want to make any change I can merge this as is.
| RUN apk add --no-cache git nodejs npm python3 make g++ | ||
| RUN cd / ; git clone https://github.com/NetrisTV/ws-scrcpy.git |
There was a problem hiding this comment.
It makes no sense to clone the project again. Is it possible to reuse the data from the projects root? Then there is also will be no need to install git in the third line.
If we move Dockerfile to the projects root, then we can do it like this:
ADD . /ws-scrcpy
RUN apk add --no-cache nodejs npm python3 make g++
WORKDIR /ws-scrcpy|
|
||
| RUN apk add --no-cache git nodejs npm python3 make g++ | ||
| RUN cd / ; git clone https://github.com/NetrisTV/ws-scrcpy.git | ||
| RUN cd /ws-scrcpy ; npm install |
There was a problem hiding this comment.
To actually build the project you need to call npm run dist after. When it finishes, you will have the distribution inside the dist directory.
Since we don't really want to copy dev-deps from node_modules and don't want to install build tools on the "runner" we should again run npm install, but now from inside the dist.
RUN npm install
RUN npm run dist
WORKDIR dist
RUN npm install| LABEL maintainer="Vitaly Repin <vitaly.repin@gmail.com>" | ||
|
|
||
| RUN apk add --no-cache android-tools npm | ||
| COPY --from=builder /ws-scrcpy /root/ws-scrcpy |
There was a problem hiding this comment.
If you used npm run dist on the "builder" you need to copy from /ws-scrcpy/dist.
COPY --from=builder /ws-scrcpy/dist /root/ws-scrcpy| COPY assets/run.sh / | ||
| RUN chmod +x /run.sh | ||
|
|
||
| CMD ["/run.sh", "--"] |
There was a problem hiding this comment.
Do we need this file? Will not this be enough?
WORKDIR /root/ws-scrcpy
CMD ["npm", "start"]| To build docker image | ||
|
|
||
| docker build -t wsscrcpy:latest . | ||
|
|
||
| To run: | ||
|
|
||
| docker run --rm -i -t --privileged -v /dev/bus/usb:/dev/bus/usb -p 127.0.0.1:8000:8000/tcp wsscrcpy:latest |
There was a problem hiding this comment.
You can add this to the main README, after Build and Start section.
|
To be clear, I don't want to maintain the docker image (or actually provide any kind of a prebuild distribution), so if you want to merge this you will take responsibility for maintaining it. Meaning I will call you (like this @vitalyrepin) every time someone asks about docker. P.S. I'm not sure about publishing on dockerhub. This project probably will not be qualified for the docker open source program. UPD: but it should be possible to publish it on GitHub Packages |
|
@vitalyrepin You should remove old files from |
DEV-18306 [ramiel] Error: ENOENT: no such file or directory, scandir '/tmp/ramiel_file_lock'
I suggest to add dockerization. It would be great to have official ws-scrcpy image at dockerhub.