diff --git a/.dockerignore b/.dockerignore index 37ec1c9ff1dd..f630b719f083 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,18 @@ -* -!**/*.so -!**/*.dll -!*.rsc -!*.dmb -!maps/* -!config/* -!tools/* -!map_config/* -!nano/* \ No newline at end of file +/.git +/*.txt +/tmp +/data +/cfg +/scripts +/.gitlab +/.vscode +/.gitlab-ci.yml +/tools/dmitool +/tools/runtimes +/local.db* +*.dll +*.exe +*.bat +*.rsc.dyn +*.log +*.lk diff --git a/.gitattributes b/.gitattributes index 5a4ddd7c5e29..24b7e0c3934b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,3 +13,6 @@ html/changelog.html merge=union *.dm text eol=lf *.dmm text eol=lf *.dme text eol=lf +*.yml text eol=lf +*.sh text eol=lf +Dockerfile eol=lf diff --git a/.gitignore b/.gitignore index 6e5d6b933cd5..0c461cefc378 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ Thumbs.db *.db-wal data/ cfg/ +!cfg/.keep tmp/ dmdoc/ tools/Runtime Condenser/Input.txt diff --git a/Dockerfile b/Dockerfile index bc8c50ed68e0..a5e49b90163a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,19 @@ -ARG BYOND_BASE_IMAGE=i386/ubuntu:bionic +# 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 -FROM ${BYOND_BASE_IMAGE} AS byond -RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y make man curl unzip libssl-dev +ARG BYOND_BASE_IMAGE=i386/ubuntu:bionic ARG BYOND_MAJOR=513 ARG BYOND_MINOR=1542 +ARG NODE_VERSION=15 +ARG PYTHON_VERSION=3.7 + +# Base BYOND image +FROM --platform=linux/386 ${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 +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 \ @@ -12,6 +22,7 @@ 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 @@ -19,11 +30,76 @@ WORKDIR /cm COPY map_config map_config COPY maps maps COPY nano nano -ARG RUSTG_LIBRARY_FILE=librust_g.so -ADD ${RUSTG_LIBRARY_FILE} librust_g.so +COPY librust_g.so . COPY tools/runner-entrypoint.sh /entrypoint.sh RUN chmod u+x /entrypoint.sh -ARG DM_PROJECT_NAME=ColonialMarinesALPHA -COPY ${DM_PROJECT_NAME}.dmb application.dmb -COPY ${DM_PROJECT_NAME}.rsc application.rsc +COPY ColonialMarinesALPHA.dmb application.dmb +COPY ColonialMarinesALPHA.rsc application.rsc ENTRYPOINT ["/entrypoint.sh"] + +# Image used for building the game with DreamMaker +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/* + +# TGUI deps prep (cache stage - keep only base structure) +FROM node:${NODE_VERSION}-buster AS tgui-thin +WORKDIR /tgui +COPY 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) +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 + +# 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 + +# 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 +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 + +# 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 +WORKDIR /build +COPY --from=tgui-build /tgui/public tgui/public +RUN source /byond/bin/byondsetup && DreamMaker ColonialMarinesALPHA.dme + +# Deployment container piecing everything together for use +FROM byond AS deploy +ENV DREAMDAEMON_PORT=1400 +RUN mkdir -p /cm/data +COPY tools/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 +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 +ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/cfg/.keep b/cfg/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 491866a2c14e..aa3b9d87f6c8 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -29,9 +29,9 @@ Basics, the most important. /datum/config_entry/string/dburl -// Shutdown instead of restarting +/// Shutdown server instead of actually restarting when using /world/Reboot() /datum/config_entry/flag/no_restarts - config_entry_value = FALSE + config_entry_value = TRUE /// URL for the CentCom Galactic Ban DB API /datum/config_entry/string/centcom_ban_db diff --git a/config/example/dbconfig_docker.txt b/config/example/dbconfig_docker.txt new file mode 100644 index 000000000000..fa7496a85f7c --- /dev/null +++ b/config/example/dbconfig_docker.txt @@ -0,0 +1,19 @@ +# file to use with the bundled docker-compose environment, drop it as config/dbconfig.txt + +# server adapter +DB_PROVIDER brsql + +# server address +DB_ADDRESS cm13-mysql + +# server port +DB_PORT 3306 + +# server db +DB_DATABASE cm13 + +# server login +DB_USERNAME cm13 + +# server password +DB_PASSWORD cm13testing diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000000..eee6ff2cfcfa --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,56 @@ +version: '3.6' + +services: + # You will probably want to copy config/example/dbconfig_docker.txt to config/dbconfig.txt to use this + cm13-mysql: + image: mysql:8 + command: mysqld --default-authentication-plugin=mysql_native_password + restart: always + ports: + - 3306:3306 + environment: + MYSQL_DATABASE: cm13 + MYSQL_USER: cm13 + MYSQL_PASSWORD: cm13testing + MYSQL_ROOT_PASSWORD: cm13testingroot + volumes: + - cm13-mysql:/var/lib/mysql + networks: + - cm13-net + + cm13-game: + build: + context: . + target: deploy + ports: + - 51400:1400 + volumes: + - type: bind + source: ./cfg + target: /usr/local/byond/cfg + - type: bind + source: ./data + target: /cm/data + - type: bind + source: ./config + target: /cm/config + read_only: true + - type: bind + source: ./map_config + target: /cm/map_config + read_only: true + - type: bind + source: ./maps + target: /cm/maps + read_only: true + networks: + - cm13-net + depends_on: + - cm13-mysql + +volumes: + cm13-mysql: + +networks: + cm13-net: + driver: bridge diff --git a/tgui/bin/tgui b/tgui/bin/tgui index 365b404b2312..c88d27fa6bef 100644 --- a/tgui/bin/tgui +++ b/tgui/bin/tgui @@ -50,6 +50,18 @@ task-install() { yarn install } +## Install deps in CI mode +task-install-deps() { + cd "${base_dir}" + yarn install --immutable +} + +## Check deps in CI mode +task-install-check() { + cd "${base_dir}" + yarn install --immutable --immutable-cache +} + ## Runs webpack task-webpack() { cd "${base_dir}" @@ -124,6 +136,16 @@ task-merge-bundle() { ## Main ## -------------------------------------------------------- +if [[ ${1} == "--deps-only" ]]; then + task-install-deps + exit 0 +fi + +if [[ ${1} == "--deps-check" ]]; then + task-install-check + exit 0 +fi + if [[ ${1} == "--merge"* ]]; then if [[ ${1} == "--merge=bundle" ]]; then shift 1 diff --git a/tools/runner-entrypoint.sh b/tools/runner-entrypoint.sh index 69fe97c8ce49..571e0b1673bd 100644 --- a/tools/runner-entrypoint.sh +++ b/tools/runner-entrypoint.sh @@ -1,3 +1,3 @@ #!/bin/bash source /byond/bin/byondsetup -DreamDaemon application.dmb ${DREAMDAEMON_PORT} -trusted \ No newline at end of file +exec DreamDaemon application.dmb ${DREAMDAEMON_PORT} -trusted