diff --git a/.gitignore b/.gitignore index 70068265..1501c42b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ node_modules npm-debug.log* yarn-debug.log* yarn-error.log* +docker/log/** # Editor directories and files .idea diff --git a/README.md b/README.md index 71adde53..a1b100d4 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,16 @@ npm run build ### Customize the configuration See [Configuring quasar.conf.js](https://v2.quasar.dev/quasar-cli/quasar-conf-js). + +## Docker + +Docker image can be created by the exection of the docker build script. +In this process, vircadia web sdk (https://github.com/vircadia/vircadia-web-sdk) will be cloned and compiled. There is a product "vircadia-web-sdk-[VERSION].tgz" where VERION is the web-sdk version. Consult the vircadia-web-sdk doc for the exact version number. As of 2/8/2022, the default version is 2022.1.2. Make sure that the right version is passed when execute it. +The version argument is passed at the build-docker.sh "--build-arg WEB_SDK_VER". +Port 8080 is open for this. Its log can be found at the local "log" directory. + +``` +cd docker && ./build-docker.sh +``` + +Docker image "vercadia-web" will be created and this image can be used as a part of docker-compose. Please consult vircadia-domain-server-docker (https://github.com/vircadia/vircadia-domain-server-docker). diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..e761c292 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,62 @@ +FROM ubuntu:20.04 as web-base + +RUN apt update && apt install -y git curl +RUN curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh && \ + bash ./nodesource_setup.sh && \ + apt install nodejs && \ + rm ./nodesource_setup.sh + +FROM web-base as web-sdk-builder +RUN apt update +# checkout repo +RUN mkdir -p /usr/local/src && \ + cd /usr/local/src && \ + git clone --depth 1 --branch master https://github.com/vircadia/vircadia-web-sdk.git + +RUN cd /usr/local/src/vircadia-web-sdk && \ + npm install && npm run build && npm pack + +FROM web-base +# RUN apt update +RUN npm install -g @vue/cli && npm install -g @quasar/cli + +# Default is 2022.1.2. Make sure this version alligns with web-sdk version. +ARG WEB_SDK_VER=2022.1.2 + +# default is 'vircadia' +ARG REPO=vircadia +# default is 'master' +ARG BRANCH=master + +# checkout repo +RUN mkdir -p /usr/local/src && \ + cd /usr/local/src && \ + git clone --depth 1 --branch ${BRANCH} https://github.com/${REPO}/vircadia-web.git + +COPY --from=web-sdk-builder /usr/local/src/vircadia-web-sdk/vircadia-web-sdk-${WEB_SDK_VER}.tgz /usr/local/src/ +RUN cd /usr/local/src && \ + tar zxvf vircadia-web-sdk-${WEB_SDK_VER}.tgz && npm install -g ./package + +RUN cd /usr/local/src/vircadia-web && npm i && npm run build + +ENV USER=cadia +ENV VIRCADIAWEB=vircadia-web + +# Add a user for the server to run under +RUN adduser --disabled-password --gecos 'vircadia user' ${USER} + +RUN apt update && apt install -y sudo vim +RUN usermod -aG sudo ${USER} && \ + echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \ + cp /root/.bashrc /home/${USER}/ && \ + chown -R --from=root ${USER}:${USER} /home/${USER} && \ + touch $HOME/.sudo_as_admin_successful +ENV PATH /home/developer/.local/bin:$PATH + +WORKDIR /home/${USER} +USER ${USER}:${USER} +RUN mkdir -p /home/${USER}/${VIRCADIAWEB}/log +COPY --chown=${USER}:${USER} ./files/run-vircadia-web.sh /home/${USER}/ + +EXPOSE 8080 +ENTRYPOINT [ "/home/cadia/run-vircadia-web.sh" ] diff --git a/docker/build-docker.sh b/docker/build-docker.sh new file mode 100755 index 00000000..f66c7d19 --- /dev/null +++ b/docker/build-docker.sh @@ -0,0 +1,11 @@ +#! /bin/bash +if [ -z "$1" ] +then + WEB_SDK_VER=2022.1.2 + echo "Vircadia Web SDK version is not supplied." +else + WEB_SDK_VER=$1 +fi +echo "Vircadia Web SDK version ${WEB_SDK_VER} is used." + +docker build -t vircadia-web --build-arg WEB_SDK_VER=${WEB_SDK_VER} . diff --git a/docker/files/run-vircadia-web.sh b/docker/files/run-vircadia-web.sh new file mode 100755 index 00000000..6e68d607 --- /dev/null +++ b/docker/files/run-vircadia-web.sh @@ -0,0 +1,16 @@ +#! /bin/bash + +BASE=/home/cadia/vircadia-web + +# Default location for logs is in the Iamus sub-directory +LOGDIR=${BASE}/log +# If a log directory is provided in the mounted 'config' dir, use that one +if [[ -d "/home/cadia/vircadia-web/log" ]] ; then + LOGDIR=/home/cadia/vircadia-web/log +fi +mkdir -p "${LOGDIR}" + +LOGFILE=${LOGDIR}/$(date --utc "+%Y%m%d.%H%M").log +echo "Log file: ${LOGFILE}" +cd /usr/local/src/vircadia-web +sudo npm run dev >> ${LOGFILE} 2>&1 diff --git a/docker/run-docker-vircadia-web.sh b/docker/run-docker-vircadia-web.sh new file mode 100755 index 00000000..bdfce919 --- /dev/null +++ b/docker/run-docker-vircadia-web.sh @@ -0,0 +1,15 @@ +#! /bin/bash +# Start the metaverseserver with persistant data in local dir + +BASE=$(pwd) +cd "${BASE}" + +DVERSION=latest + +docker run -it --rm \ + --name=vircadia-web \ + -p 8080:8080 \ + -p 8081:8081 \ + -p 8082:8082 \ + --volume ${BASE}/log:/home/cadia/vircadia-web/log \ + vircadia-web:${DVERSION} diff --git a/docker/vircadia-web-sdk-2022.1.1.tgz b/docker/vircadia-web-sdk-2022.1.1.tgz new file mode 100644 index 00000000..4cc8ba20 Binary files /dev/null and b/docker/vircadia-web-sdk-2022.1.1.tgz differ diff --git a/src/config.ts b/src/config.ts index 05f67f10..11741013 100644 --- a/src/config.ts +++ b/src/config.ts @@ -33,6 +33,9 @@ export const FalseValue = "false"; export const DefaultConfig: { [key: string]: string } = { "Default_Metaverse_Url": "https://metaverse.vircadia.com/live", + // docker compose metaverse + // "Default_Metaverse_Url": "http://localhost:9400", + ////// "Default_Domain_Protocol": "wss:", "Default_Domain_Port": "40102" }; diff --git a/src/vircadia-web-sdk.d.ts b/src/vircadia-web-sdk.d.ts index f48df382..9e7ee59b 100644 --- a/src/vircadia-web-sdk.d.ts +++ b/src/vircadia-web-sdk.d.ts @@ -240,5 +240,4 @@ declare module "@vircadia/web-sdk" { get avatarList(): AvatarListInterface; update(): void; } - } diff --git a/tsconfig.json b/tsconfig.json index f47d9e9c..27476dde 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,5 +11,4 @@ "@Store/*": ["./src/store/*"] } } - }