-
Notifications
You must be signed in to change notification settings - Fork 54
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
Summary: Add docker support. #47
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
FROM ubuntu:20.04 as web-base | ||
|
||
RUN apt update && apt install -y git curl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah... it doesn't hurt. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah... it doesn't hurt. |
||
RUN curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh && \ | ||
bash ./nodesource_setup.sh && \ | ||
apt install nodejs && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This installs NodeJS v14. The SDK's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering what would be the right. if so, let's update to 16. |
||
rm ./nodesource_setup.sh | ||
|
||
FROM web-base as web-sdk-builder | ||
RUN apt update | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this 'update' necessary since it was done in the base image? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah... drop it. |
||
# checkout repo | ||
RUN mkdir -p /usr/local/src && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Docker layer caching might use a cached layer even if the v-web sources have changed, adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea!!! Add this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this line causes an error like following: 21 40.93 npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. Any idea why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw those errors also but figured they were related to v-web-sdk configuration/versioning. Maybe need a revisit of the v-web-sdk build independent of the Docker image. Wonder what v-web-sdk has for package-lock and other requirements. |
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this 'update' necessary since we are derived from 'web-base'? |
||
RUN usermod -aG sudo ${USER} && \ | ||
echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure adding to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it is only dev and debug. Will comment it out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the proper command to run the app? |
||
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" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I first ran the image, I got the error:
which says that the mounted log directory didn't have the permissions to create files in the mounted directory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. need to change how it runs the app. For now it requires sudo. I am going to drop 'sudo' and move app to /home/cadia. Let me do it. |
||
--name=vircadia-web \ | ||
-p 8080:8080 \ | ||
-p 8081:8081 \ | ||
-p 8082:8082 \ | ||
--volume ${BASE}/log:/home/cadia/vircadia-web/log \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be a "--detach" to run the container as a service in the background. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is to be a service, add a "--restart=unless-stopped" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
vircadia-web:${DVERSION} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enhance this comment to say this is a debugging option. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. will update the comment. |
||
// "Default_Metaverse_Url": "http://localhost:9400", | ||
////// | ||
"Default_Domain_Protocol": "wss:", | ||
"Default_Domain_Port": "40102" | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,5 +240,4 @@ declare module "@vircadia/web-sdk" { | |
get avatarList(): AvatarListInterface; | ||
update(): void; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,4 @@ | |
"@Store/*": ["./src/store/*"] | ||
} | ||
} | ||
|
||
} |
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.
Should use
apt-get
instead of plainapt
to get rid of the warning "WARNING: apt does not have a stable CLI interface. Use with caution in scripts."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.
sure!