Skip to content

Commit

Permalink
Update and optimize meta tester and inflator images
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Dec 16, 2023
1 parent d43a2ac commit dc28347
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 13 deletions.
58 changes: 50 additions & 8 deletions Dockerfile.metadata
Original file line number Diff line number Diff line change
@@ -1,15 +1,57 @@
FROM mono:latest
# Everything we need in both the build and prod images
FROM ubuntu:latest as base

RUN /bin/sed -i 's/^mozilla\/DST_Root_CA_X3.crt$/!mozilla\/DST_Root_CA_X3.crt/' /etc/ca-certificates.conf && \
/usr/sbin/update-ca-certificates
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 python3-pip python3-setuptools git build-essential python3-dev libffi-dev && \
apt-get clean
# Don't prompt for time zone
ENV DEBIAN_FRONTEND=noninteractive

# Put user-installed Python code in path
ENV PATH "$PATH:/root/.local/bin"

# Install Git and Python
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates gnupg git libffi-dev \
python3 python-is-python3

# Trust all git repos
RUN git config --global --add safe.directory '*'

# Set up Mono's APT repo
RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list \
&& apt-get update

# Install the necessary pieces of Mono
RUN apt-get install -y --no-install-recommends \
mono-runtime ca-certificates-mono libmono-microsoft-csharp4.0-cil libmono-system-data4.0-cil libmono-system-runtime-serialization4.0-cil libmono-system-transactions4.0-cil libmono-system-net-http-webrequest4.0-cil

# Isolate Python build stuff in a separate container
FROM base as build

# Install Python build deps
RUN apt-get install -y --no-install-recommends \
python3-pip python3-setuptools python3-dev

# Install the meta tester's Python code and its Infra dep
ENV PIP_ROOT_USER_ACTION=ignore
RUN pip3 install --upgrade pip
RUN pip3 install 'git+https://github.com/KSP-CKAN/NetKAN-Infra#subdirectory=netkan'
RUN pip3 install 'git+https://github.com/KSP-CKAN/xKAN-meta_testing'
RUN pip3 install --user 'git+https://github.com/KSP-CKAN/NetKAN-Infra#subdirectory=netkan'
RUN pip3 install --user 'git+https://github.com/KSP-CKAN/xKAN-meta_testing'

# Prune unused deps (`--user` is implicit for uninstall)
RUN pip3 --no-input uninstall -y flask gunicorn werkzeug

# The image we'll actually use
FROM base as prod

# Purge APT download cache, package lists, and logs
RUN apt-get clean \
&& rm -r /var/lib/apt/lists /var/log/dpkg.log /var/log/apt

# Extract built Python packages from the build image
COPY --from=build /root/.local /root/.local

# Install the .NET assemblies the meta tester uses
ADD netkan.exe /usr/local/bin/.
ADD ckan.exe /usr/local/bin/.

Expand Down
25 changes: 21 additions & 4 deletions Dockerfile.netkan
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
FROM mono:latest
RUN /bin/sed -i 's/^mozilla\/DST_Root_CA_X3.crt$/!mozilla\/DST_Root_CA_X3.crt/' /etc/ca-certificates.conf && \
/usr/sbin/update-ca-certificates
FROM ubuntu:latest

# Don't prompt for time zone
ENV DEBIAN_FRONTEND=noninteractive

# Set up Mono's APT repo
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates gnupg curl \
&& gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list \
&& apt-get update

# Install the necessary pieces of Mono
RUN apt-get install -y --no-install-recommends \
mono-runtime ca-certificates-mono libmono-microsoft-csharp4.0-cil libmono-system-data4.0-cil libmono-system-runtime-serialization4.0-cil libmono-system-transactions4.0-cil libmono-system-net-http-webrequest4.0-cil

# Purge APT download cache, package lists, and logs
RUN apt-get clean \
&& rm -r /var/lib/apt/lists /var/log/dpkg.log /var/log/apt

RUN useradd -ms /bin/bash netkan
USER netkan
WORKDIR /home/netkan
ADD netkan.exe .
ADD --chown=netkan netkan.exe .
ENTRYPOINT /usr/bin/mono netkan.exe --game ${GAME:-KSP} --queues $QUEUES \
--net-useragent 'Mozilla/5.0 (compatible; Netkanbot/1.0; CKAN; +https://github.com/KSP-CKAN/NetKAN-Infra)' \
--github-token $GH_Token --gitlab-token "$GL_Token" --cachedir ckan_cache -v
2 changes: 1 addition & 1 deletion doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ The basic operation of the actual build process is as follows:
These are the "final" output of the build process and are stored in: `_build/repack/$CONFIGURATION`.
- Unit tests are executed
- The NUnit unit tests in `CKAN.Tests.dll` are executed.
- Smoke tets are executed
- Smoke tests are executed
- These are simple tests designed to make sure there isn't anything grossly wrong with the build. All they do is
execute the repacked `ckan.exe` and `netkan.exe` and make sure their version output matches the expected output.

Expand Down

0 comments on commit dc28347

Please sign in to comment.