Skip to content

Commit

Permalink
Merge pull request #34 from defold/split-docker-image
Browse files Browse the repository at this point in the history
Splits the Dockerfile into two.
  • Loading branch information
king-lothman authored Mar 28, 2017
2 parents a174609 + bbba134 commit e5eb9da
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 128 deletions.
115 changes: 115 additions & 0 deletions server/docker-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
FROM ubuntu:16.04

# Base stuff
RUN \
dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
apt-get install -y --no-install-recommends \
oracle-java8-installer \
wine \
gcc \
g++ \
libssl-dev \
openssl \
libtool \
autoconf \
automake \
uuid-dev \
libxi-dev \
libopenal-dev \
libgl1-mesa-dev \
libglw1-mesa-dev \
freeglut3-dev \
unzip && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/oracle-jdk8-installer

# Android SDK/NDK
ENV ANDROID_ROOT /opt/android
ENV ANDROID_SDK_FILENAME android-sdk_r24.3.3-linux.tgz
ENV ANDROID_SDK_URL http://dl.google.com/android/${ANDROID_SDK_FILENAME}
ENV ANDROID_BUILD_TOOLS_VERSION 23.0.2
ENV ANDROID_HOME ${ANDROID_ROOT}/android-sdk-linux

ENV ANDROID_NDK_VERSION 10e
ENV ANDROID_NDK_API_VERSION 14
ENV ANDROID_TARGET_API_LEVEL 23
ENV ANDROID_MIN_API_LEVEL 9
ENV ANDROID_GCC_VERSION 4.8
ENV ANDROID_NDK_PATH ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}
ENV ANDROID_NDK_INCLUDE ${ANDROID_ROOT}/tmp/android-ndk-r${ANDROID_NDK_VERSION}/platforms/android-${ANDROID_NDK_API_VERSION}/arch-arm/usr/include
ENV ANDROID_STL_INCLUDE ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VERSION}/include
ENV ANDROID_STL_ARCH_INCLUDE ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VERSION}/libs/armeabi-v7a/include
ENV ANDROID_STL_LIB ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VERSION}/libs/armeabi-v7a
ENV ANDROID_SYSROOT ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/platforms/android-${ANDROID_NDK_API_VERSION}/arch-arm
ENV ANDROID_BIN_PATH ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/toolchains/arm-linux-androideabi-${ANDROID_GCC_VERSION}/prebuilt/linux-x86_64/bin
ENV ANDROID_SDK_BUILD_TOOLS_PATH ${ANDROID_ROOT}/android-sdk/build-tools/${ANDROID_BUILD_TOOLS_VERSION}

ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_BIN_PATH}:${ANDROID_SDK_BUILD_TOOLS_PATH}

ENV ANDROID_NDK_FILENAME android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip
ENV ANDROID_NDK_URL https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}

RUN mkdir -p cd ${ANDROID_ROOT} && \
cd ${ANDROID_ROOT} && \
wget -q -O - ${ANDROID_SDK_URL} | tar -zxvf - && \
echo y | android update sdk --no-ui -a --filter tools,platform-tools,android-${ANDROID_TARGET_API_LEVEL},build-tools-${ANDROID_BUILD_TOOLS_VERSION} && \
ln -s android-sdk-linux android-sdk && \
wget -q ${ANDROID_NDK_URL} && \
chmod +x ${ANDROID_NDK_FILENAME} && \
unzip ${ANDROID_NDK_FILENAME} && \
chmod +r -R ${ANDROID_ROOT} && \
rm ${ANDROID_NDK_FILENAME} && \
chmod -R 755 ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}

ENV S3_URL https://s3-eu-west-1.amazonaws.com/defold-packages

RUN wget -q -O - ${S3_URL}/clang%2Bllvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJ -C /usr/local --strip-components=1

# Windows
ENV PROGRAM_FILES "/root/.wine/drive_c/Program Files"

RUN \
mkdir -p "/root/.wine/drive_c/windows/system32" && \
wget -P /usr/bin ${S3_URL}/prepreg-vc10-dx09-32.exe && \
ls /root/.wine/drive_c/windows/system32 && \
mkdir -p "${PROGRAM_FILES}" && \
wget -q -O - ${S3_URL}/Microsoft-Visual-Studio-10.0.tar.gz | tar xz -C "${PROGRAM_FILES}"

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN \
apt-get update && \
apt-get install -y git && \
cd /tmp && \
git clone https://github.com/tpoechtrager/cctools-port.git && \
cd cctools-port/cctools && \
git checkout 84ce22dbb22a26ce7f392e9de0ee39c2efe6fd68 && \
./autogen.sh && \
./configure --prefix=/usr/local --target=arm-apple-darwin11 && \
make -j8 && \
make install && \
make distclean && \
./autogen.sh && \
./configure --prefix=/usr/local --target=x86_64-apple-darwin11 && \
make -j8 && \
make install && \
apt-get remove -y git

# Right now, the package contains iPhoneOS.sdk, in the future, we want iPhoneOS9.3.sdk
RUN \
wget -q -O - ${S3_URL}/iPhoneOS9.3.sdk.tar.gz | tar xz -C /opt && \
mv /opt/iPhoneOS.sdk /opt/iPhoneOS9.3.sdk && \
ln -s /opt/iPhoneOS9.3.sdk /opt/iPhoneOS.sdk && \
wget -q -O - ${S3_URL}/MacOSX10.11.sdk.tar.gz | tar xz -C /opt && \
ln -s /usr/local/bin/llvm-dsymutil /usr/local/bin/dsymutil && \
ln -s /usr/local/bin/clang /usr/local/bin/arm-apple-darwin11-clang && \
ln -s /usr/local/bin/clang /usr/local/bin/x86_64-apple-darwin11-clang && \
ln -s /usr/local/bin/llvm-ar /usr/local/bin/x86_64-apple-darwin11-clang-ar
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
132 changes: 6 additions & 126 deletions server/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,131 +1,11 @@
FROM ubuntu:16.04
FROM extender-base

# Base stuff
RUN apt-get update && apt-get install -y software-properties-common
RUN dpkg --add-architecture i386
RUN \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y\
curl \
oracle-java8-installer \
wine \
git \
gcc \
g++ \
libssl-dev \
openssl \
libtool \
autoconf \
automake \
ccache \
uuid-dev \
libxi-dev \
libopenal-dev \
valgrind python-setuptools \
libgl1-mesa-dev \
libglw1-mesa-dev \
freeglut3-dev \
unzip && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/oracle-jdk8-installer

# Android SDK/NDK
ENV ANDROID_ROOT /opt/android
ENV ANDROID_SDK_FILENAME android-sdk_r24.3.3-linux.tgz
ENV ANDROID_SDK_URL http://dl.google.com/android/${ANDROID_SDK_FILENAME}
ENV ANDROID_BUILD_TOOLS_VERSION 23.0.2
ENV ANDROID_HOME ${ANDROID_ROOT}/android-sdk-linux

ENV ANDROID_NDK_VERSION 10e
ENV ANDROID_NDK_API_VERSION 14
ENV ANDROID_TARGET_API_LEVEL 23
ENV ANDROID_MIN_API_LEVEL 9
ENV ANDROID_GCC_VERSION 4.8
ENV ANDROID_NDK_PATH ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}
ENV ANDROID_NDK_INCLUDE ${ANDROID_ROOT}/tmp/android-ndk-r${ANDROID_NDK_VERSION}/platforms/android-${ANDROID_NDK_API_VERSION}/arch-arm/usr/include
ENV ANDROID_STL_INCLUDE ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VERSION}/include
ENV ANDROID_STL_ARCH_INCLUDE ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VERSION}/libs/armeabi-v7a/include
ENV ANDROID_STL_LIB ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VERSION}/libs/armeabi-v7a
ENV ANDROID_SYSROOT ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/platforms/android-${ANDROID_NDK_API_VERSION}/arch-arm
ENV ANDROID_BIN_PATH ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}/toolchains/arm-linux-androideabi-${ANDROID_GCC_VERSION}/prebuilt/linux-x86_64/bin
ENV ANDROID_SDK_BUILD_TOOLS_PATH ${ANDROID_ROOT}/android-sdk/build-tools/${ANDROID_BUILD_TOOLS_VERSION}

ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_BIN_PATH}:${ANDROID_SDK_BUILD_TOOLS_PATH}
RUN mkdir -p cd ${ANDROID_ROOT} && \
cd ${ANDROID_ROOT} && \
wget -q ${ANDROID_SDK_URL} && \
tar -xzf ${ANDROID_SDK_FILENAME} && \
rm ${ANDROID_SDK_FILENAME} && \
echo y | android update sdk --no-ui -a --filter tools,platform-tools,android-${ANDROID_TARGET_API_LEVEL},build-tools-${ANDROID_BUILD_TOOLS_VERSION} && \
ln -s android-sdk-linux android-sdk

ENV ANDROID_NDK_FILENAME android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip
ENV ANDROID_NDK_URL https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}

RUN cd ${ANDROID_ROOT} && \
wget -q ${ANDROID_NDK_URL} && \
chmod +x ${ANDROID_NDK_FILENAME} && \
unzip ${ANDROID_NDK_FILENAME} && \
chmod +r -R ${ANDROID_ROOT} && \
rm ${ANDROID_NDK_FILENAME}

ENV S3_URL https://s3-eu-west-1.amazonaws.com/defold-packages

RUN wget -q -O - ${S3_URL}/clang%2Bllvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJ -C /usr/local --strip-components=1

# Windows
ENV PROGRAM_FILES "/root/.wine/drive_c/Program Files"

RUN mkdir -p "/root/.wine/drive_c/windows/system32"
RUN wget -P /usr/bin ${S3_URL}/prepreg-vc10-dx09-32.exe
RUN ls /root/.wine/drive_c/windows/system32


RUN mkdir -p "${PROGRAM_FILES}"

RUN wget -q -O - ${S3_URL}/Microsoft-Visual-Studio-10.0.tar.gz | tar xz -C "${PROGRAM_FILES}"

RUN useradd builder

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8


ADD hw.c /tmp
ADD test.sh /tmp
ADD build-darwin-toolchain.sh /tmp
RUN /tmp/build-darwin-toolchain.sh 84ce22dbb22a26ce7f392e9de0ee39c2efe6fd68

# Right now, the package contains iPhoneOS.sdk, in the future, we want iPhoneOS9.3.sdk
RUN wget -q -O - ${S3_URL}/iPhoneOS9.3.sdk.tar.gz | tar xz -C /opt
# Until we've fixed the package
RUN mv /opt/iPhoneOS.sdk /opt/iPhoneOS9.3.sdk
# backwards compatible
RUN ln -s /opt/iPhoneOS9.3.sdk /opt/iPhoneOS.sdk

RUN wget -q -O - ${S3_URL}/MacOSX10.11.sdk.tar.gz | tar xz -C /opt

RUN ln -s /usr/local/bin/llvm-dsymutil /usr/local/bin/dsymutil
RUN ln -s /usr/local/bin/clang /usr/local/bin/arm-apple-darwin11-clang
RUN ln -s /usr/local/bin/clang /usr/local/bin/x86_64-apple-darwin11-clang
RUN ln -s /usr/local/bin/llvm-ar /usr/local/bin/x86_64-apple-darwin11-clang-ar

ADD test-ios-toolchain.sh /tmp

# Create user "extender" with fixed user ID and run the webapp as that user.
RUN useradd -r -u 2222 extender

RUN mkdir -p /var/extender
RUN chown extender: /var/extender

RUN chown extender: $(readlink -f /usr/bin/java)
RUN chmod +s $(readlink -f /usr/bin/java)

RUN chmod -R 755 ${ANDROID_ROOT}/android-ndk-r${ANDROID_NDK_VERSION}
useradd -r -u 2222 extender && \
mkdir -p /var/extender && \
chown extender: /var/extender && \
chown extender: $(readlink -f /usr/bin/java) && \
chmod +s $(readlink -f /usr/bin/java)

USER extender

Expand Down
6 changes: 5 additions & 1 deletion server/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

${DIR}/../../gradlew buildDocker
docker build -t extender-base ${DIR}/../docker-base

${DIR}/../../gradlew buildDocker
2 changes: 2 additions & 0 deletions server/scripts/start-test-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

docker build -t extender-base ${DIR}/../docker-base

${DIR}/../../gradlew buildDocker -x test

docker run -d --rm --name extender -p 9000:9000 -v ${DIR}/../test-data/sdk:/var/extender/sdk extender/extender
2 changes: 1 addition & 1 deletion server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ server:

extender:
sdk-location: /var/extender/sdk
sdk-cache-size: 3
sdk-cache-size: 10 # Slightly bigger than production in order to not remove version controlled SDK
build-location: /var/extender/builds

spring.http.multipart.max-file-size: 500mb
Expand Down

0 comments on commit e5eb9da

Please sign in to comment.