From 62a33b0022077d0f82cf379dc954cbf0ea974636 Mon Sep 17 00:00:00 2001 From: Adrian Priestley Date: Sat, 28 Dec 2024 11:43:44 -0330 Subject: [PATCH] feat(docker): Add initial Docker configuration for project - Add .dockerignore file to ignore unnecessary files - Create Dockerfile with basic build and deployment configuration --- .dockerignore | 7 ++++++ Dockerfile | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..0a74ad63a5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +.github +.run +docs +test +typings +*Client.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..889857309d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,66 @@ +# hadolint global ignore=SC1090,SC1091 + +ARG ARCHITECTURE=$(uname -m) + +#Source +FROM scratch AS release +WORKDIR /release +#Not sure how to build this project. Grab release instead. +ADD https://github.com/Ijwu/Enemizer/releases/latest/download/ubuntu.16.04-x64.zip Enemizer.zip + +#Enemizer +FROM alpine:3.21 AS enemizer +WORKDIR /release +COPY --from=release /release/Enemizer.zip . +#No release for arm architecture. Skip. +RUN if [ "$ARCHITECTURE" = "x86_64" ]; then \ + apk add unzip=6.0-r15 --no-cache; \ + unzip -u Enemizer.zip -d EnemizerCLI; \ + chmod -R 777 EnemizerCLI; \ + else touch EnemizerCLI; fi + +#Archipelago +FROM python:3.12-slim AS archipelago +ENV VIRTUAL_ENV=/opt/venv +WORKDIR /run +COPY . . + +#install requirements +RUN apt-get update; \ + apt-get install -y --no-install-recommends \ + git=1:2.39.5-0+deb12u1 \ + gcc=4:12.2.0-3 \ + libc6-dev=2.36-9+deb12u9 \ + libtk8.6=8.6.13-2 \ + g++=4:12.2.0-3; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* + +#create and activate venv +RUN python -m venv $VIRTUAL_ENV; \ + . $VIRTUAL_ENV/bin/activate + +#hadolint ignore=DL3042 +RUN pip install -r WebHostLib/requirements.txt; \ + python ModuleUpdate.py -y + +RUN cythonize -i _speedups.pyx + +#purge unneeded packages +RUN apt-get purge \ + git \ + gcc \ + libc6-dev \ + g++; \ + apt-get autoremove + +# Copy necessary components +COPY --from=enemizer /release/EnemizerCLI /tmp/EnemizerCLI + +#No release for arm architecture. Skip. +RUN if [ "$ARCHITECTURE" = "x86_64" ]; then \ + cp /tmp/EnemizerCLI EnemizerCLI; \ + fi; \ + rm -rf /tmp/EnemizerCLI + +CMD ["python", "WebHost.py"]