From 0f0f2d04fd5d047c639688dbdce7d9c56e309ce1 Mon Sep 17 00:00:00 2001 From: anthonyliao Date: Tue, 14 Mar 2023 01:35:51 -0400 Subject: [PATCH] dockerize app and make available over html via novnc --- Dockerfile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ overviews.sh | 0 2 files changed, 54 insertions(+) create mode 100644 Dockerfile mode change 100644 => 100755 overviews.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2c161a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +FROM ubuntu:22.04 as build + +RUN apt-get update \ + && apt-get install -y --no-install-recommends libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev fonts-dejavu curl ca-certificates git gcc \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* + +# Install Go +ARG GO_VERSION=1.18.10 +RUN curl -L https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz --output go${GO_VERSION}.linux-amd64.tar.gz \ + && rm -rf /usr/local/go \ + && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz +ENV PATH=$PATH:/usr/local/go/bin + +WORKDIR /csgoverview + +COPY . . + +RUN go build + +# Download map images +RUN chmod 755 overviews.sh && ./overviews.sh + + +FROM ubuntu:22.04 as runtime + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends dumb-init x11vnc xvfb novnc libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev fonts-dejavu zenity \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1001 ubuntu +USER ubuntu +WORKDIR /home/ubuntu + +COPY --from=build /csgoverview/csgoverview csgoverview/ + +# Copy map overviews into the correct location +RUN mkdir -p /home/ubuntu/.local/share/csgoverview/assets/maps +COPY --from=build /csgoverview/overviews/*.jpg /home/ubuntu/.local/share/csgoverview/assets/maps/ + +# Script that will start a x11 server (xvfb), vnc server (x11vnc), and expose vnc over htmml (novnc) +RUN echo "#!/bin/bash\n\ +x11vnc -create -env FD_PROG='/home/ubuntu/csgoverview/csgoverview' -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 -env X11VNC_CREATE_GEOM=${1:-1624x1024x16} -nopw -loop & \n\ +/usr/share/novnc/utils/launch.sh --listen 6081 --vnc localhost:5900" > ~/run.sh +RUN chmod 755 ~/run.sh + +# Create volume mount where users can put their demos +RUN mkdir -p /home/ubuntu/demos +VOLUME /home/ubuntu/demos + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +CMD ["/home/ubuntu/run.sh"] \ No newline at end of file diff --git a/overviews.sh b/overviews.sh old mode 100644 new mode 100755