| 1 |
# Dockerfile for cross-compiling for DMS in its different architectures. |
| 2 |
# |
| 3 |
# Build the Docker image: |
| 4 |
# docker build -t dms-build-env -f /path/to/your/sdk/dockerfile/dms-cross-build.dockerfile /path/to/your/sdk/dockerfile/ --build-arg PLATFORM=platformName |
| 5 |
# -t : Tags the built container with a name |
| 6 |
# -f : Specify dockerfile to be build, replace /path/to/your/sdk with your local path to the sdk |
| 7 |
# --build-arg : adds an argument to the build, you should select one of the possible architectures |
| 8 |
# |
| 9 |
# Run the Docker container and build the project for a specific architecture: |
| 10 |
# docker run -v /path/to/your/sdk:/mega/sdk -v /path/to/your/vcpkg:/mega/vcpkg -it dms-build-env |
| 11 |
# -v : Mounts a local directory into the container, replace /path/to/your/sdk and /path/to/your/vcpkg with your local paths |
| 12 |
# -it : Starts an interactive terminal session inside the container after the cmake project is configured and build |
| 13 |
# |
| 14 |
# Possible platforms are: [alpine alpine4k apollolake armada37xx armada38x avoton broadwell broadwellnk broadwellnkv2 broadwellntbap bromolow braswell denverton epyc7002 geminilake grantley kvmx64 monaco purley r1000 rtd1296 rtd1619b v1000] |
| 15 |
|
| 16 |
# Base image |
| 17 |
FROM ubuntu:22.04 |
| 18 |
|
| 19 |
# Set default architecture |
| 20 |
ARG PLATFORM=alpine |
| 21 |
ENV PLATFORM=${PLATFORM} |
| 22 |
|
| 23 |
# Install dependencies |
| 24 |
RUN apt-get --quiet=2 update && DEBCONF_NOWARNINGS=yes apt-get --quiet=2 install \ |
| 25 |
aria2 \ |
| 26 |
autoconf \ |
| 27 |
autoconf-archive \ |
| 28 |
build-essential \ |
| 29 |
cmake \ |
| 30 |
curl \ |
| 31 |
fakeroot \ |
| 32 |
git \ |
| 33 |
libtool \ |
| 34 |
nasm \ |
| 35 |
pkg-config \ |
| 36 |
python3 \ |
| 37 |
tar \ |
| 38 |
unzip \ |
| 39 |
wget \ |
| 40 |
xz-utils \ |
| 41 |
zip \ |
| 42 |
1> /dev/null |
| 43 |
|
| 44 |
# Install AWS CLI v2 |
| 45 |
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ |
| 46 |
unzip awscliv2.zip && \ |
| 47 |
./aws/install && \ |
| 48 |
rm -rf awscliv2.zip aws |
| 49 |
|
| 50 |
# Set up work directory |
| 51 |
WORKDIR /mega |
| 52 |
|
| 53 |
RUN chmod 777 /mega |
| 54 |
|
| 55 |
# Clone and checkout known pkgscripts baseline |
| 56 |
RUN git clone https://github.com/SynologyOpenSource/pkgscripts-ng.git pkgscripts \ |
| 57 |
&& git -C ./pkgscripts checkout e1d9f52 |
| 58 |
|
| 59 |
# Copy the shell script and configuration files |
| 60 |
COPY dms-toolchain.sh /mega/ |
| 61 |
COPY dms-toolchains.conf /mega/ |
| 62 |
|
| 63 |
# Make the helper shell script executable |
| 64 |
RUN chmod +x /mega/dms-toolchain.sh |
| 65 |
|
| 66 |
# Configure and build CMake command |
| 67 |
CMD ["sh", "-c", "\ |
| 68 |
owner_uid=$(stat -c '%u' /mega/sdk) && \ |
| 69 |
owner_gid=$(stat -c '%g' /mega/sdk) && \ |
| 70 |
groupadd -g $owner_gid me && \ |
| 71 |
echo 'Adding \"me\" user...' && \ |
| 72 |
useradd -r -M -u $owner_uid -g $owner_gid -d /mega -s /bin/bash me && \ |
| 73 |
export PLATFORM=${PLATFORM} && \ |
| 74 |
su - me -w 'PLATFORM,VCPKG_BINARY_SOURCES,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_ENDPOINT_URL' -c ' \ |
| 75 |
/mega/dms-toolchain.sh ${PLATFORM} && \ |
| 76 |
cmake -B buildDMS -S sdk \ |
| 77 |
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ |
| 78 |
-DENABLE_LOG_PERFORMANCE=ON \ |
| 79 |
-DENABLE_SDKLIB_EXAMPLES=OFF \ |
| 80 |
-DENABLE_SDKLIB_TESTS=OFF \ |
| 81 |
-DENABLE_SDKLIB_WERROR=OFF \ |
| 82 |
-DUSE_LIBUV=ON \ |
| 83 |
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/mega/${PLATFORM}.toolchain.cmake \ |
| 84 |
-DVCPKG_OVERLAY_TRIPLETS=/mega \ |
| 85 |
-DVCPKG_ROOT=/mega/vcpkg \ |
| 86 |
-DVCPKG_TARGET_TRIPLET=${PLATFORM} && \ |
| 87 |
cmake --build buildDMS' && \ |
| 88 |
exec /bin/bash"] |