Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vitalyrepin
Copy link

I suggest to add dockerization. It would be great to have official ws-scrcpy image at dockerhub.

Copy link
Collaborator

@drauggres drauggres left a 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.

Comment on lines 3 to 4
RUN apk add --no-cache git nodejs npm python3 make g++
RUN cd / ; git clone https://github.com/NetrisTV/ws-scrcpy.git
Copy link
Collaborator

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


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
Copy link
Collaborator

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

LABEL maintainer="Vitaly Repin <[email protected]>"

RUN apk add --no-cache android-tools npm
COPY --from=builder /ws-scrcpy /root/ws-scrcpy
Copy link
Collaborator

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

COPY assets/run.sh /
RUN chmod +x /run.sh

CMD ["/run.sh", "--"]
Copy link
Collaborator

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
Comment on lines 1 to 7
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
Copy link
Collaborator

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.

@drauggres
Copy link
Collaborator

drauggres commented Oct 7, 2021

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

@drauggres drauggres mentioned this pull request Oct 7, 2021
@drauggres drauggres linked an issue Oct 7, 2021 that may be closed by this pull request
@drauggres
Copy link
Collaborator

@vitalyrepin You should remove old files from /docker.
Also, before merging this, I need your confirmation that you are willing to maintain this, because I am not.

@vitalyrepin vitalyrepin closed this Nov 1, 2021
@vitalyrepin vitalyrepin reopened this Nov 1, 2021
maxduke pushed a commit to maxduke/ws-scrcpy that referenced this pull request Aug 10, 2023
DEV-18306 [ramiel] Error: ENOENT: no such file or directory, scandir '/tmp/ramiel_file_lock'
superen7527 added a commit to superen7527/scrcpyweb that referenced this pull request Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker support
2 participants