feat(docker): Add initial Docker configuration for project

- Add .dockerignore file to ignore unnecessary files
- Create Dockerfile with basic build and deployment configuration
This commit is contained in:
Adrian Priestley
2024-12-28 11:43:44 -03:30
committed by Adrian Priestley
parent 1cef659b78
commit 62a33b0022
2 changed files with 73 additions and 0 deletions

7
.dockerignore Normal file
View File

@@ -0,0 +1,7 @@
.git
.github
.run
docs
test
typings
*Client.py

66
Dockerfile Normal file
View File

@@ -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"]