Skip to content

Commit

Permalink
GItHub/Juke/Docker integration for live game (cmss13-devs#27)
Browse files Browse the repository at this point in the history
Odds and ends to integrate upcoming docker build based system with Juke and such as we're putting in place here
  • Loading branch information
fira authored Apr 15, 2022
1 parent c666d8a commit bf75e18
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 68 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/.git
/.gitlab-ci.yml
/.github
/.vscode
/*.txt
/bin
/tmp
/data
/cfg
/scripts
/.gitlab
/.vscode
/.gitlab-ci.yml
/tools/dmitool
/tools/runtimes
/local.db*
Expand All @@ -16,3 +19,4 @@
*.rsc.dyn
*.log
*.lk

122 changes: 57 additions & 65 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,105 +1,97 @@
# TODO: Replace 80% of that cache handling with juke tasks
# so contributors can have reproducible test builds without needing docker...
# Also will allow to properly handle building game in map checking mode
# TODO: Use an .envfile and make everyone use it instead
ARG BYOND_BASE_IMAGE=ubuntu:focal
ARG UTILITY_BASE_IMAGE=alpine:3
ARG PROJECT_NAME=ColonialMarinesALPHA
ARG BYOND_MAJOR=514
ARG BYOND_MINOR=1575
ARG NODE_VERSION=16
ARG BYOND_UID=1000

ARG BYOND_BASE_IMAGE=i386/ubuntu:bionic
ARG BYOND_MAJOR=513
ARG BYOND_MINOR=1542
ARG NODE_VERSION=15
ARG PYTHON_VERSION=3.7
# BUILD_TYPE=standalone to build with juke in docker
# BUILD_TYPE=deploy to directly use already built local files
# This will only work properly with later docker version! If it doesn't try launching with DOCKER_BUILDKIT=1 env variable
ARG BUILD_TYPE=deploy

# Base BYOND image
FROM --platform=linux/386 ${BYOND_BASE_IMAGE} AS byond
FROM ${BYOND_BASE_IMAGE} AS byond
SHELL ["/bin/bash", "-c"]
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y make man curl unzip libssl-dev
RUN dpkg --add-architecture i386
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y make man curl unzip libssl-dev libssl-dev:i386 libz-dev:i386 lib32stdc++6
ARG BYOND_MAJOR
ARG BYOND_MINOR
ARG BYOND_DOWNLOAD_URL=https://secure.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip
RUN curl ${BYOND_DOWNLOAD_URL} -o byond.zip \
&& unzip byond.zip \
&& rm -rf byond.zip
RUN DEBIAN_FRONTEND=noninteractive apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /byond
RUN make here
RUN DEBIAN_FRONTEND=noninteractive apt-get clean && rm -rf /var/lib/apt/lists/*

# Legacy GitLab CI packaging container, using pre-built game in pipeline
FROM byond AS cm-runner
ENV DREAMDAEMON_PORT=1400
RUN mkdir -p /cm/data
WORKDIR /cm
COPY map_config map_config
COPY maps maps
COPY nano nano
COPY librust_g.so .
COPY tools/runner-entrypoint.sh /entrypoint.sh
RUN chmod u+x /entrypoint.sh
COPY ColonialMarinesALPHA.dmb application.dmb
COPY ColonialMarinesALPHA.rsc application.rsc
ENTRYPOINT ["/entrypoint.sh"]

# Image used for building the game with DreamMaker
# DM Build Env to be used in particular with juke if not running it locally
FROM byond AS cm-builder
ARG DM_PROJECT_NAME
ARG PYTHON_VERSION
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y python${PYTHON_VERSION} python3-pip
RUN pip3 install python-dateutil requests beautifulsoup4 pyyaml
RUN DEBIAN_FRONTEND=noninteractive apt-get clean && rm -rf /var/lib/apt/lists/*
COPY tools/docker/nodesource.gpg /usr/share/keyrings/nodesource.gpg
COPY tools/docker/nodesource.list /etc/apt/sources.list.d/
COPY tools/docker/apt-node-prefs /etc/apt/preferences/
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y nodejs yarn g++-multilib && apt-get clean && rm -rf /var/lib/apt/lists/*

# TGUI deps prep (cache stage - keep only base structure)
# TGUI deps pre-caching, thin out files to serve as basis for layer caching
FROM node:${NODE_VERSION}-buster AS tgui-thin
WORKDIR /tgui
COPY tgui .
COPY tgui /tgui
RUN rm -rf docs public
RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf

# TGUI deps fetch (cache stage - keep deps as standalone layer)
# TGUI deps cache layer, actually gets the deps
FROM node:${NODE_VERSION}-buster AS tgui-deps
COPY --from=tgui-thin tgui /tgui
WORKDIR /tgui
RUN chmod u+x bin/tgui && bin/tgui --deps-only
RUN yarn install --immutable

# TGUI builder
FROM node:${NODE_VERSION}-buster AS tgui-build
WORKDIR /tgui
COPY --from=tgui-deps /tgui/.yarn/cache .yarn/cache
COPY tgui .
RUN chmod u+x bin/tgui && bin/tgui --deps-check && bin/tgui
RUN rm -rf .yarn/cache
# Game source cache stage: remove irrelevant dupes not dockerignored to prevent cache misses
FROM ${UTILITY_BASE_IMAGE} AS source-cache
COPY . /src
WORKDIR /src
RUN rm -rf *.rsc *.dmb

# More cache shenanigans, trim uneeded build context for layer caching DM build
# this ensures modifying eg. dynamic maps don't force a game rebuild, as we just add them at end regardless
# *.txt is the changelog date marker (uses gitlab project ID)
FROM byond AS cm-cache
COPY . /build
# Stage actually building with juke if needed
FROM cm-builder AS cm-build-standalone
ARG PROJECT_NAME
COPY --from=source-cache /src /build
WORKDIR /build
RUN rm -rf tgui config strings maps map_config tools *.txt
# Copy back the few files we need during DM build
COPY maps/_basemap.dm maps/
COPY maps/map_files/generic maps/map_files/generic
COPY --from=tgui-deps /tgui/.yarn/cache tgui/.yarn/cache
RUN ./tools/docker/juke-build.sh

# Actual game building stage. We include tgui here because it'll be packed in RSC file
FROM cm-builder AS cm-build
COPY --from=cm-cache /build /build
# Helper Stage just packaging locally provided resources
FROM ${UTILITY_BASE_IMAGE} AS cm-build-deploy
ARG PROJECT_NAME
RUN mkdir /build
WORKDIR /build
COPY --from=tgui-build /tgui/public tgui/public
RUN source /byond/bin/byondsetup && DreamMaker ColonialMarinesALPHA.dme
COPY tgui/public tgui/public
COPY ${PROJECT_NAME}.dmb ${PROJECT_NAME}.dmb
COPY ${PROJECT_NAME}.rsc ${PROJECT_NAME}.rsc

# Alias for using either of the above
FROM cm-build-${BUILD_TYPE} AS build-results

# Deployment container piecing everything together for use
# Deployment stage, piecing a workable game image
FROM byond AS deploy
ARG PROJECT_NAME
ARG BYOND_UID
ENV DREAMDAEMON_PORT=1400
RUN mkdir -p /cm/data
COPY tools/runner-entrypoint.sh /entrypoint.sh
COPY tools/docker/runner-entrypoint.sh /entrypoint.sh
RUN chmod u+x /entrypoint.sh
RUN useradd -ms /bin/bash byond
RUN chown -R byond:byond /byond /cm /entrypoint.sh
RUN useradd -u ${BYOND_UID} -ms /bin/bash byond
WORKDIR /cm
USER byond
COPY librust_g.so .
COPY config config
COPY map_config map_config
COPY strings strings
COPY nano nano
COPY maps maps
COPY --from=cm-build /build/ColonialMarinesALPHA.rsc application.rsc
COPY --from=cm-build /build/ColonialMarinesALPHA.dmb application.dmb
COPY html html
COPY --from=build-results /build/tgui/public tgui/public/
COPY --from=build-results /build/${PROJECT_NAME}.dmb application.dmb
COPY --from=build-results /build/${PROJECT_NAME}.rsc application.rsc
RUN chown -R byond:byond /byond /cm /entrypoint.sh
USER ${BYOND_UID}
ENTRYPOINT [ "/entrypoint.sh" ]
3 changes: 1 addition & 2 deletions tgui/packages/tgui-panel/styles/goon/chat-dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ em {
}

.ooc {
color: #cca300;
font-weight: bold;
}

Expand All @@ -303,7 +302,7 @@ em {
}

.adminsay {
color: #ff4500;
color: #9611D4;
font-weight: bold;
}

Expand Down
3 changes: 3 additions & 0 deletions tools/docker/apt-node-prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Package: *
Pin: origin deb.nodesource.com
Pin-Priority: 600
3 changes: 3 additions & 0 deletions tools/docker/juke-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
source /byond/bin/byondsetup
exec ./tools/build/build
Binary file added tools/docker/nodesource.gpg
Binary file not shown.
2 changes: 2 additions & 0 deletions tools/docker/nodesource.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x focal main
deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x focal main
File renamed without changes.

0 comments on commit bf75e18

Please sign in to comment.