Archived
2
0

easy development tools.

This commit is contained in:
m1k1o 2021-04-01 23:18:50 +02:00
parent 24699ec512
commit 70860ab83c
7 changed files with 165 additions and 5 deletions

18
.m1k1o/.env.default Normal file
View File

@ -0,0 +1,18 @@
#
# you can copy this file to .env.local, if you don't want to have it pushed to repository
#
# this is how will be your images called. you can change it to your fork.
# only need to do this once. here.
BUILD_IMAGE="m1k1o/neko"
# this is where your services will be acessible
CLIENT_PORT=8080
SERVER_PORT=8081
# on which image you want to test it
SERVER_TAG="chromium"
# this is needed for WebRTC. specify your local IP address and free UDP port range.
SERVER_EPR=55000-55009
SERVER_IP=10.8.0.1

39
.m1k1o/README.md Normal file
View File

@ -0,0 +1,39 @@
# How to contribute to neko
If you want to contribute, but don't want to install anything on your host system, we got you covered. You only need docker. Technically, it could be donw using vs code development in container, but this is more fun:).
You need to copy `.env.development` to `.env` and customize values.
## Step 1: Building server
- `./build` - You can use this command to build your specified `SERVER_TAG` along with base image.
If you want, you can build other tags. `base` tag needs to be build first:
- `./build base`
- `./build firefox`
- `./build chromium`
- etc...
## Step 2: Starting server
- `./start-server` - Starting server image you specified in `.env`.
- `./start-server -r` - Shortcut for rebuilding server binary and then starting.
If you are changing something in the server code, you don't want to rebuild container each time. You can just rebuild your binary:
- `./rebuild-server` - Rebuild only server binary.
- `./rebuild-server -f` - Force to rebuild whole golang environment (you should do this only of you change some dependencies).
## Step 3: Seving client
- `./serve-client` - Serving vue.js client.
- `./serve-client -i` - Install all depenencies.
## Debug
You can navigate to `CLIENT_PORT` and see live client there. It will be connected to your local server on `SERVER_PORT`.
If you are leaving client as is and not changing it, you don't need to start `./serve-client` and you can access server's GUI directly on `SERVER_PORT`.
Feel free to open new PR.

View File

@ -2,7 +2,24 @@
cd "$(dirname "$0")" cd "$(dirname "$0")"
BASE="${PWD}/../" BASE="${PWD}/../"
IMAGE="m1k1o/neko"
if [ -f ".env.default" ]
then
export $(cat .env.default | sed 's/#.*//g' | xargs)
fi
if [ -f ".env" ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
if [ -z "${1}" ] && [ ! -z "${SERVER_TAG}" ]
then
./build base
./build ${SERVER_TAG}
exit 0
fi
build_client() { build_client() {
docker build -t neko-dev-client -f base/Dockerfile --target client "${BASE}" docker build -t neko-dev-client -f base/Dockerfile --target client "${BASE}"
@ -24,10 +41,10 @@ build() {
if [ "$1" = "base" ] if [ "$1" = "base" ]
then then
# build base # build base
docker build -t "${IMAGE}:base" -f base/Dockerfile "${BASE}" docker build -t "${BUILD_IMAGE}:base" -f base/Dockerfile "${BASE}"
else else
# buld image # buld image
docker build -t "${IMAGE}:$1" -f "$1/Dockerfile" "$1/" docker build -t "${BUILD_IMAGE}:$1" --build-arg="BASE_IMAGE=${BUILD_IMAGE}:base" -f "$1/Dockerfile" "$1/"
fi fi
} }
@ -35,10 +52,10 @@ build_arm() {
if [ "$1" = "base" ] if [ "$1" = "base" ]
then then
# build ARM base # build ARM base
docker build -t "${IMAGE}:arm-base" -f arm-base/Dockerfile "${BASE}" docker build -t "${BUILD_IMAGE}:arm-base" -f arm-base/Dockerfile "${BASE}"
else else
# buld ARM image # buld ARM image
docker build -t "${IMAGE}:arm-$1" --build-arg="BASE_IMAGE=${IMAGE}:arm-base" -f "$1/Dockerfile" "$1/" docker build -t "${BUILD_IMAGE}:arm-$1" --build-arg="BASE_IMAGE=${BUILD_IMAGE}:arm-base" -f "$1/Dockerfile" "$1/"
fi fi
} }

21
.m1k1o/rebuild-server Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
if [ -f ".env.default" ]
then
export $(cat .env.default | sed 's/#.*//g' | xargs)
fi
if [ -f ".env" ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
# use -f to force rebuild
if [ "$(docker images -q neko_dev_server 2> /dev/null)" == "" ] || [ "$1" == "-f" ]; then
docker build -t neko_dev_server -f base/Dockerfile --target server ../
fi
docker run --rm -it \
-v "${PWD}/../server:/src" \
--entrypoint="go" \
neko_dev_server build -o "bin/neko" -i "cmd/neko/main.go"

29
.m1k1o/serve-client Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
if [ -f ".env.default" ]
then
export $(cat .env.default | sed 's/#.*//g' | xargs)
fi
if [ -f ".env" ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
# use -i to install
if [ ! -d "${PWD}/../client/node_modules" ] || [ "$1" == "-i" ]; then
docker run --rm -it \
-v "${PWD}/../client:/app" \
--workdir="/app" \
--entrypoint="npm" \
node:14-buster-slim install
fi
docker run --rm -it \
-p "${CLIENT_PORT}:8080" \
-v "${PWD}/../client:/app" \
-e "VUE_APP_SERVER_PORT=${SERVER_PORT}" \
--workdir="/app" \
--entrypoint="npm" \
node:14-buster-slim run serve

32
.m1k1o/start-server Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
if [ -f ".env.default" ]
then
export $(cat .env.default | sed 's/#.*//g' | xargs)
fi
if [ -f ".env" ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
BINARY_PATH="${PWD}/../server/bin/neko"
# use -r to rebuild
if [ ! -f "${BINARY_PATH}" ] || [ "$1" == "-r" ]; then
./rebuild-server
fi
docker run --rm -it \
--name "neko_dev" \
-p "${SERVER_PORT}:8080" \
-p "${SERVER_EPR}:${SERVER_EPR}/udp" \
-e "NEKO_SCREEN=1920x1080@60" \
-e "NEKO_EPR=${SERVER_EPR}" \
-e "NEKO_NAT1TO1=${SERVER_IP}" \
-e "NEKO_ICELITE=true" \
-e "NEKO_MAX_FPS=25" \
-v "${BINARY_PATH}:/usr/bin/neko" \
--shm-size=2G \
--cap-add SYS_ADMIN \
${BUILD_IMAGE}:${SERVER_TAG}

View File

@ -272,3 +272,7 @@ NEKO_KEY:
- e.g. '/certs/key.pem' - e.g. '/certs/key.pem'
``` ```
# How to contribute?
Navigate to `.m1k1o/README.md` for further information.