diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..20172f5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +dist +data diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..629a9e3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM node:17 as build + +WORKDIR /app + +ADD package.json /app +ADD package-lock.json /app + +RUN npm install + +COPY src /app/src +COPY bin /app/bin +ADD tsconfig.json /app + +RUN npx tsc + +FROM node:17 + +RUN apt update && \ + apt install -y android-tools-adb && \ + apt-get clean + +WORKDIR /app + +ADD package.json /app +ADD package-lock.json /app + +RUN npm ci --production + +COPY bin /app/bin +COPY resources /app/resources +COPY --from=build /app/dist /app/dist + +RUN ln -s /data/android /root/.android + +VOLUME [ "/data" ] + +ENTRYPOINT [ "/app/resources/docker-entrypoint.sh" ] +CMD [ "--help" ] diff --git a/README.md b/README.md index 5a7761b..5832e0d 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,27 @@ nxapi Access the Nintendo Switch Online and Nintendo Switch Parental Controls app APIs. Includes Discord Rich Presence and friend notifications. +### Install + +#### Install from source + +Node.js and npm must already be installed. + +```sh +git clone https://gitlab.fancy.org.uk/samuel/nxapi.git # or download as an archive +cd nxapi + +# Install locally +npm install +npx tsc +npm link + +# Build Docker image +docker build . --tag gitlab.fancy.org.uk:5005/samuel/nxapi +# # Run in Docker +# docker run -it --rm -v ./data:/data gitlab.fancy.org.uk:5005/samuel/nxapi ... +``` + ### Nintendo Switch Online #### Login to the Nintendo Switch Online app @@ -257,7 +278,7 @@ nxapi pctl dump-summaries summaries --device 0123456789abcdef # This will only show cached data and does not make any requests to Nintendo servers nxapi users list -# User a specific user in a command +# Use a specific user in a command nxapi ... --user 0123456789abcdef nxapi ... --token $NA_SESSION_TOKEN @@ -300,7 +321,7 @@ This requires: - adb is installed on the computer running nxapi - The Android device is running adbd as root or a su-like command can be used to escalate to root -- The frida-server executable to be located at `/data/local/tmp/frida-server` on the Android device +- The frida-server executable is located at `/data/local/tmp/frida-server` on the Android device - The Nintendo Switch Online app is installed on the Android device The Android device must be constantly reachable using ADB. The server will exit if the device is unreachable. diff --git a/resources/docker-entrypoint.sh b/resources/docker-entrypoint.sh new file mode 100755 index 0000000..29fbbf9 --- /dev/null +++ b/resources/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +mkdir -p /data/android + +exec /app/bin/nxapi.js --data-path /data $@