Skip to content

Commit

Permalink
Merge branch 'dev' into dev-standalone-android
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Jan 22, 2024
2 parents 5516402 + b0c04dd commit dd11815
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 58 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ subprojects {
}

wrapper {
gradleVersion = '6.9'
gradleVersion = '8.4'
distributionType = Wrapper.DistributionType.ALL
}

Expand Down
2 changes: 1 addition & 1 deletion client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repositories {
}

jar {
baseName = 'extender-client'
archiveBaseName = 'extender-client'
version = '0.0.5'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.Header;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.message.AbstractHttpMessage;
import org.apache.http.message.BasicHeader;
import org.apache.http.entity.ByteArrayEntity;
Expand Down Expand Up @@ -379,6 +381,18 @@ private static final String getRelativePath(File base, File path) {
return base.toURI().relativize(path.toURI()).getPath();
}

// Left for future debugging
public String httpRequestToString(HttpRequestBase request) {
StringBuilder sb = new StringBuilder();
sb.append("Request " + request.getMethod() + " " + request.getURI() + "\n");
sb.append("Headers = {\n");
for (Header header : request.getAllHeaders()) {
sb.append(" " + header.getName() + " = " + header.getValue() + ",\n");
}
sb.append("}\n");
return sb.toString();
}

public boolean health() throws IOException {
HttpGet request = new HttpGet(extenderBaseUrl);
addAuthorizationHeader(request);
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
42 changes: 27 additions & 15 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ buildscript {
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE'
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.6.6'

// Updating to gradle 7, means moving from this plugin to something else
classpath 'se.transmode.gradle:gradle-docker:1.2'
}
}

Expand All @@ -19,11 +16,14 @@ plugins {
id 'idea'
id 'eclipse'
id 'org.springframework.boot' version '2.6.6'
id 'com.bmuschko.docker-remote-api' version '7.2.0'
}

apply plugin: 'docker'
apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'io.spring.dependency-management'

import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage

configurations {
// A configuration meant for consumers that need the API of this component
implementation {
Expand Down Expand Up @@ -109,6 +109,7 @@ public class Version {
def template = engine.createTemplate(text).make(binding)

new File(projectDir.toString() + "/src/main/java/com/defold/extender", "Version.java").text = template.toString()
project.ext.set("outSha", sha)
}

compileJava {
Expand All @@ -117,44 +118,55 @@ compileJava {

// Creates the full jar file, with the extender server classes included
bootJar {
baseName = 'extender'
archiveBaseName = 'extender'
version = '0.1.0'
}

// Builds the extender server base classes into a .jar file
jar {
baseName = 'extender-base'
archiveBaseName = 'extender-base'
version = '0.1.0'
archiveClassifier = '' // use empty string to avoid the 'plain' suffix
}

task buildDocker(type: Docker) {
dependsOn 'build', ':manifestmergetool:mainJar'
push = false
applicationName = bootJar.baseName
dockerfile = file('docker/Dockerfile')
File dockerBuildDir = new File(project.buildDir, 'docker-stage');

task dockerStageDir {
doFirst {
if (dockerBuildDir.exists()) {
dockerBuildDir.delete();
}
dockerBuildDir.mkdirs();
copy {
from(project.projectDir) {
include "users/**"
}
into stageDir
into dockerBuildDir
}
copy {
from bootJar
into stageDir
into dockerBuildDir
}
copy {
from project(':manifestmergetool').collect { it.tasks.withType(Jar) }
into stageDir
into dockerBuildDir
}
copy {
from 'docker'
into stageDir
into dockerBuildDir
}
}
}

task buildDocker(type: DockerBuildImage) {
dependsOn 'build', ':manifestmergetool:mainJar', 'dockerStageDir'
inputDir = dockerBuildDir
imageId = bootJar.archiveBaseName
dockerFile = new File(dockerBuildDir, 'Dockerfile')
images.add("extender/extender:latest")
images.add("extender/extender:" + project.outSha)
}

task buildStandalone() {
dependsOn 'build', ':manifestmergetool:mainJar'
doLast {
Expand Down
46 changes: 11 additions & 35 deletions server/docker-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ RUN \
echo "LINUX TOOLS + COMPILER" && \
apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:openjdk-r/ppa && \
apt-get update && \
apt-get install -y --no-install-recommends \
wget \
Expand Down Expand Up @@ -453,6 +452,14 @@ RUN \
mkdir -p ${NINTENDO_SDK_ROOT_15_3_2} && \
wget -q -O - ${DM_PACKAGES_URL}/${SWITCH_SDK_15_FILENAME} | tar xz -C ${NINTENDO_SDK_ROOT_15_3_2}

ENV NINTENDO_SDK_ROOT_17_5 ${PLATFORMSDK_DIR}/nx-17.5.3
ENV SWITCH_SDK_17_FILENAME nx64-sdk-17.5.3.tar.gz

RUN \
echo "Switch SDK 17.5.3" && \
mkdir -p ${NINTENDO_SDK_ROOT_17_5} && \
wget -q -O - ${DM_PACKAGES_URL}/${SWITCH_SDK_17_FILENAME} | tar xz -C ${NINTENDO_SDK_ROOT_17_5}

#
# PS4 SDK
#
Expand Down Expand Up @@ -537,10 +544,9 @@ RUN \
# Versions: https://developer.android.com/studio/releases/gradle-plugin?buildsystem=ndk-build#updating-gradle
# Java+Gradle version matrix: https://docs.gradle.org/current/userguide/compatibility.html
ENV GRADLE_USER_HOME /tmp/.gradle
ENV GRADLE_VERSION 8.0.2
#ENV GRADLE_PLUGIN_VERSION 8.0.2 # "Android Gradle plugin requires Java 17 to run. You are currently using Java 11."
ENV GRADLE_PLUGIN_VERSION 7.4.0
ENV GRADLE_JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV GRADLE_JAVA_HOME /usr/local/jdk-17.0.7+7
ENV GRADLE_VERSION 8.4
ENV GRADLE_PLUGIN_VERSION 8.2.1
ENV PATH ${PATH}:/opt/gradle/gradle-${GRADLE_VERSION}/bin
RUN \
echo "Gradle" && \
Expand Down Expand Up @@ -587,35 +593,5 @@ RUN \
apt-get remove -y apt-transport-https xvfb && \
apt-get clean autoclean autoremove


# To avoid the mysterious error "Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty"
# # From https://github.com/docker-library/openjdk/blob/master/11/jdk/slim/Dockerfile
RUN \
apt-get update; \
apt-get install -y --no-install-recommends \
# utilities for keeping Debian and OpenJDK CA certificates in sync
ca-certificates p11-kit \
; \
# update "cacerts" bundle to use Debian's CA certificates (and make sure it stays up-to-date with changes to Debian's store)
# see https://github.com/docker-library/openjdk/issues/327
# http://rabexc.org/posts/certificates-not-working-java#comment-4099504075
# https://salsa.debian.org/java-team/ca-certificates-java/blob/3e51a84e9104823319abeb31f880580e46f45a98/debian/jks-keystore.hook.in
# https://git.alpinelinux.org/aports/tree/community/java-cacerts/APKBUILD?id=761af65f38b4570093461e6546dcf6b179d2b624#n29
{ \
echo '#!/usr/bin/env bash'; \
echo 'set -Eeuo pipefail'; \
echo 'if ! [ -d "$JAVA_HOME" ]; then echo >&2 "error: missing JAVA_HOME environment variable"; exit 1; fi'; \
# 8-jdk uses "$JAVA_HOME/jre/lib/security/cacerts" and 8-jre and 11+ uses "$JAVA_HOME/lib/security/cacerts" directly (no "jre" directory)
echo 'cacertsFile=; for f in "$JAVA_HOME/lib/security/cacerts" "$JAVA_HOME/jre/lib/security/cacerts"; do if [ -e "$f" ]; then cacertsFile="$f"; break; fi; done'; \
echo 'if [ -z "$cacertsFile" ] || ! [ -f "$cacertsFile" ]; then echo >&2 "error: failed to find cacerts file in $JAVA_HOME"; exit 1; fi'; \
echo 'trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$cacertsFile"'; \
} > /etc/ca-certificates/update.d/docker-openjdk; \
chmod +x /etc/ca-certificates/update.d/docker-openjdk; \
/etc/ca-certificates/update.d/docker-openjdk; \
\
# https://github.com/docker-library/openjdk/issues/331#issuecomment-498834472
find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; \
ldconfig;

# Always run last to minimize the size
RUN apt-get clean autoclean autoremove
2 changes: 2 additions & 0 deletions server/docker-base/template.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

namespace = "com.defold.defold"
}

java {
Expand Down
5 changes: 3 additions & 2 deletions server/manifestmergetool/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
apply plugin: 'java-library'

jar {
baseName = '_manifestmergetool'
archiveBaseName = '_manifestmergetool'
enabled = true
archiveClassifier = '' // use empty string to avoid the 'plain' suffix
}
Expand All @@ -22,7 +22,7 @@ configurations {

task mainJar(type: Jar) {
version = '0.1.0'
baseName = 'manifestmergetool'
archiveBaseName = 'manifestmergetool'
manifest {
attributes 'Main-Class': 'com.defold.manifestmergetool.ManifestMergeTool'
}
Expand All @@ -33,6 +33,7 @@ task mainJar(type: Jar) {
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
duplicatesStrategy DuplicatesStrategy.WARN
with jar
}

Expand Down
10 changes: 10 additions & 0 deletions server/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ if [ "${ENV}" != "" ]; then
echo "Using ENV: ${ENV}"
fi

if [ "${DM_EXTENDER_USERNAME}" != "" ]; then
echo "Found DM_EXTENDER_USERNAME, removing from test env"
unset DM_EXTENDER_USERNAME
fi

if [ "${DM_EXTENDER_PASSWORD}" != "" ]; then
echo "Found DM_EXTENDER_PASSWORD, removing from test env"
unset DM_EXTENDER_PASSWORD
fi

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

${DIR}/../../gradlew clean buildDocker --info $@
2 changes: 1 addition & 1 deletion server/scripts/standalone/service-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ start_service() {
java -Xmx2g -XX:MaxDirectMemorySize=1g -jar ${PATH_TO_JAR} --spring.profiles.active=${PROFILE} >> ${STDOUT_LOG} 2>> ${ERROR_LOG} < /dev/null &
else
echo "Running: java -Xmx2g -XX:MaxDirectMemorySize=1g -jar ${PATH_TO_JAR} --extender.sdk.location=${EXTENDER_SDK_LOCATION} --spring.profiles.active=${PROFILE} >> ${STDOUT_LOG} 2>> ${ERROR_LOG} < /dev/null &"
java -Xmx2g -XX:MaxDirectMemorySize=1g -jar ${PATH_TO_JAR} --extender.sdk.location="${EXTENDER_SDK_LOCATION}" -spring.profiles.active=${PROFILE} >> ${STDOUT_LOG} 2>> ${ERROR_LOG} < /dev/null &
java -Xmx2g -XX:MaxDirectMemorySize=1g -jar ${PATH_TO_JAR} --extender.sdk.location="${EXTENDER_SDK_LOCATION}" --spring.profiles.active=${PROFILE} >> ${STDOUT_LOG} 2>> ${ERROR_LOG} < /dev/null &
fi


Expand Down
9 changes: 8 additions & 1 deletion server/scripts/stop-test-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

CONTAINER=extender

echo "stop-test-server.sh: Output log result for ${CONTAINER}:"

docker logs ${CONTAINER}

echo "stop-test-server.sh: Stopping ${CONTAINER}:"

docker stop ${CONTAINER}

echo "stop-test-server.sh: Checking if ${CONTAINER} is still running:"

while [ "$(docker inspect -f '{{.State.Running}}' ${CONTAINER})" = "true" ]; do
echo "Test server ${CONTAINER} is still running..."
sleep 1
done

echo "Test server ${CONTAINER} exited"
echo "stop-test-server.sh: Test server ${CONTAINER} exited"

0 comments on commit dd11815

Please sign in to comment.