-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Dockerfile and ws-scrcpy startup script #150
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>"
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.
docker/Dockerfile
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
docker/Dockerfile
Outdated
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
docker/Dockerfile
Outdated
LABEL maintainer="Vitaly Repin <[email protected]>" | ||
|
||
RUN apk add --no-cache android-tools npm | ||
COPY --from=builder /ws-scrcpy /root/ws-scrcpy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
docker/Dockerfile
Outdated
COPY assets/run.sh / | ||
RUN chmod +x /run.sh | ||
|
||
CMD ["/run.sh", "--"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this file? Will not this be enough?
WORKDIR /root/ws-scrcpy
CMD ["npm", "start"]
docker/README
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.