Skip to content

Commit

Permalink
Update Docker build setup for multiple Python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterman committed Jun 14, 2023
1 parent a4e1b6c commit 57ec673
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 51 deletions.
40 changes: 13 additions & 27 deletions docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
FROM ubuntu:22.04
FROM quay.io/pypa/manylinux2014_i686

ARG sampgdk_version=4.6.2
ARG pysamp_branch=main
ARG sampgdk_ref=v4.6.2
ARG pysamp_ref=v2.1.0-rc2
ARG build_type=Release
ARG job_count=4

WORKDIR /root
ENV DEBIAN_FRONTEND=noninteractive

RUN \
dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
g++-multilib \
cmake \
git \
ca-certificates \
wget \
&& \
git clone \
--depth 1 \
--recursive \
--branch v${sampgdk_version} \
--branch ${sampgdk_ref} \
https://github.com/Zeex/sampgdk \
&& \
git clone \
Expand All @@ -33,26 +21,24 @@ RUN \
git clone \
--depth 1 \
--recursive \
--branch ${pysamp_branch} \
--branch ${pysamp_ref} \
https://github.com/pysamp/PySAMP \
&& \
mkdir sampgdk/build && \
( \
cd sampgdk/build && \
apt-get install -y --no-install-recommends python2 && \
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py -O- | python2 && \
python2 -mpip install --user ply && \
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2 && \
python2 -mpip install --user ply==3.10 && \
cmake \
.. \
-G 'Unix Makefiles' \
-DCMAKE_BUILD_TYPE=${build_type} \
-DSAMPSDK_DIR=../../samp-plugin-sdk \
-DSAMPGDK_BUILD_AMALGAMATION=ON \
&& \
make && \
apt-get remove -y --purge python2 && \
rm -rf \
/usr/local/bin/* \
/usr/local/lib/python2.7 \
) && \
apt-get install -y --no-install-recommends python3-dev:i386
make -j$(nproc) \
)

WORKDIR /root/PySAMP
COPY docker-entrypoint.sh /
CMD ["/docker-entrypoint.sh"]
11 changes: 11 additions & 0 deletions docker/build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
docker build \
--platform linux/386 \
-t pysamp/build \
. \
&&
docker run \
--platform linux/386 \
--rm -ti \
-v $PWD:/root/output \
pysamp/build
24 changes: 0 additions & 24 deletions docker/build/build_pysamp.sh

This file was deleted.

49 changes: 49 additions & 0 deletions docker/build/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
targets=(
cp36-cp36m
cp37-cp37m
cp38-cp38
cp39-cp39
cp310-cp310
cp311-cp311
)
libs_archive=/opt/_internal/static-libs-for-embedding-only.tar.xz
libcrypt_path=/usr/local/lib/libcrypt.so
config="${CONFIG:-Release}"

if [[ -e "${libs_archive}" ]]; then
(
cd /opt/_internal
tar xf "${libs_archive}"
rm "${libs_archive}"
)
fi

if grep '.so.2' "${libcrypt_path}"; then
# Force linking against libcrypt.so.1
cp "${libcrypt_path}"{.1,}
ldconfig
fi

for target in "${targets[@]}"; do
(
echo "Building for ${target}..."
export PATH="/opt/python/${target}/bin:${PATH}"
build_dir="build_${target}"
target_dir="../output/python3.$(python3 -c 'import sys; print(sys.version_info[1])')"
cmake \
-S src \
-B "build_${target}" \
-D SAMPSDK_DIR="${PWD}/../samp-plugin-sdk" \
-D SAMPGDK_DIR="${PWD}/../sampgdk" \
-D CMAKE_BUILD_TYPE="${config}" \
&&
cmake \
--build ${build_dir} \
--config "${config}" \
--parallel $(nproc) \
&&
mkdir -p ${target_dir} &&
cp "${build_dir}/PySAMP.so" ${target_dir}
)
done

0 comments on commit 57ec673

Please sign in to comment.