forked from lambci/docker-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
227 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="bin/main" path="src/main/java"> | ||
<attributes> | ||
<attribute name="gradle_scope" value="main"/> | ||
<attribute name="gradle_used_by_scope" value="main,test"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>dump-java8</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
13 changes: 13 additions & 0 deletions
13
base/dump-java8al2/.settings/org.eclipse.buildship.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
arguments= | ||
auto.sync=false | ||
build.scans.enabled=false | ||
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3)) | ||
connection.project.dir= | ||
eclipse.preferences.version=1 | ||
gradle.user.home= | ||
java.home= | ||
jvm.arguments= | ||
offline.mode=false | ||
override.workspace.settings=true | ||
show.console.view=true | ||
show.executions.view=true |
2 changes: 2 additions & 0 deletions
2
base/dump-java8al2/.settings/org.eclipse.core.resources.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apply plugin: 'java' | ||
|
||
sourceCompatibility = '1.8' | ||
targetCompatibility = '1.8' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation ( | ||
'com.amazonaws:aws-lambda-java-core:1.2.0', | ||
'com.amazonaws:aws-lambda-java-events:2.2.7', | ||
'com.amazonaws:aws-java-sdk-s3:1.11.681' | ||
) | ||
} | ||
|
||
task buildZip(type: Zip) { | ||
from compileJava | ||
from processResources | ||
into('lib') { | ||
from configurations.runtimeClasspath | ||
} | ||
} | ||
|
||
build.dependsOn buildZip | ||
|
||
// docker run --rm -v "$PWD":/app -w /app gradle:jdk8 gradle build |
88 changes: 88 additions & 0 deletions
88
base/dump-java8al2/src/main/java/org/lambci/lambda/DumpJava8.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.lambci.lambda; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.lang.InterruptedException; | ||
import java.lang.management.ManagementFactory; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.Map; | ||
import java.util.Scanner; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import com.amazonaws.services.s3.model.CannedAccessControlList; | ||
import com.amazonaws.services.s3.model.PutObjectRequest; | ||
import com.amazonaws.services.s3.model.PutObjectResult; | ||
|
||
public class DumpJava8 implements RequestHandler<Object, PutObjectResult> { | ||
|
||
@Override | ||
public PutObjectResult handleRequest(Object input, Context context) { | ||
String filename = "java8.al2.tgz"; | ||
String cmd = "tar -cpzf /tmp/" + filename + " --numeric-owner --ignore-failed-read /var/runtime /var/lang"; | ||
AmazonS3 s3client = AmazonS3ClientBuilder.standard().withRegion("us-east-1").build(); | ||
|
||
System.out.println(ManagementFactory.getRuntimeMXBean().getInputArguments().toString()); | ||
System.out.println(System.getProperty("sun.java.command")); | ||
System.out.println(System.getProperty("java.home")); | ||
System.out.println(System.getProperty("java.library.path")); | ||
System.out.println(System.getProperty("java.class.path")); | ||
System.out.println(System.getProperty("user.dir")); | ||
System.out.println(System.getProperty("user.home")); | ||
System.out.println(System.getProperty("user.name")); | ||
System.out.println(new File(".").getAbsolutePath()); | ||
Map<String, String> env = System.getenv(); | ||
for (String envName : env.keySet()) { | ||
System.out.println(envName + "=" + env.get(envName)); | ||
} | ||
|
||
try { | ||
int pid = Integer.parseInt(new File("/proc/self").getCanonicalFile().getName()); | ||
|
||
System.out.println("Parent cmdline:"); | ||
System.out.println(new String(Files.readAllBytes(Paths.get("/proc/1/cmdline"))).replace("\0", " ")); | ||
|
||
System.out.println("Parent env:"); | ||
runShell("xargs --null --max-args=1 < /proc/1/environ"); | ||
|
||
System.out.println("This cmdline:"); | ||
System.out.println(new String(Files.readAllBytes(Paths.get("/proc/" + pid + "/cmdline"))).replace("\0", " ")); | ||
|
||
System.out.println("This env:"); | ||
runShell("xargs --null --max-args=1 < /proc/" + pid + "/environ"); | ||
|
||
if (runShell(cmd) != 0) { | ||
return null; | ||
} | ||
|
||
System.out.println("Zipping done! Uploading..."); | ||
|
||
return s3client.putObject(new PutObjectRequest("lambci", "fs/" + filename, new File("/tmp/" + filename)) | ||
.withCannedAcl(CannedAccessControlList.PublicRead)); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static int runShell(String cmd) throws IOException, InterruptedException { | ||
Process process = Runtime.getRuntime().exec(new String[] { "sh", "-c", cmd }); | ||
|
||
try (Scanner stdoutScanner = new Scanner(process.getInputStream()); | ||
Scanner stderrScanner = new Scanner(process.getErrorStream())) { | ||
// Echo all stdout first | ||
while (stdoutScanner.hasNextLine()) { | ||
System.out.println(stdoutScanner.nextLine()); | ||
} | ||
// Then echo stderr | ||
while (stderrScanner.hasNextLine()) { | ||
System.err.println(stderrScanner.nextLine()); | ||
} | ||
} | ||
|
||
process.waitFor(); | ||
return process.exitValue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ | |
{ | ||
"path": "base/dump-java8" | ||
}, | ||
{ | ||
"path": "base/dump-java8al2" | ||
}, | ||
{ | ||
"path": "examples/java" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM lambci/lambda-base-2:build | ||
|
||
ENV AWS_EXECUTION_ENV=AWS_Lambda_rapid | ||
|
||
WORKDIR / | ||
|
||
RUN rm -rf /var/runtime /var/lang && \ | ||
curl https://lambci.s3.amazonaws.com/fs/java8.tgz | tar -zx -C / && \ | ||
yum install -y java-1.8.0-openjdk-devel && \ | ||
mkdir /usr/local/gradle && curl -L -o gradle.zip https://services.gradle.org/distributions/gradle-6.6-bin.zip && \ | ||
unzip -d /usr/local/gradle gradle.zip && rm gradle.zip && mkdir /usr/local/maven && \ | ||
curl -L http://mirror.cc.columbia.edu/pub/software/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | \ | ||
tar -zx -C /usr/local/maven | ||
|
||
ENV PATH="/usr/local/gradle/gradle-6.6/bin:/usr/local/maven/apache-maven-3.6.3/bin:${PATH}" | ||
|
||
# Add these as a separate layer as they get updated frequently | ||
RUN pipx install awscli==1.* && \ | ||
pipx install aws-lambda-builders==1.0.0 && \ | ||
pipx install aws-sam-cli==1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM lambci/lambda-base | ||
|
||
RUN curl https://lambci.s3.amazonaws.com/fs/java8.al2.tgz | tar -zx -C /opt | ||
|
||
|
||
FROM lambci/lambda:provided | ||
|
||
|
||
FROM lambci/lambda-base-2 | ||
|
||
ENV PATH=/var/lang/bin:$PATH \ | ||
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \ | ||
AWS_EXECUTION_ENV=AWS_Lambda_rapid | ||
|
||
COPY --from=0 /opt/* /var/ | ||
|
||
COPY --from=1 /var/runtime/init /var/rapid/init | ||
|
||
USER sbx_user1051 | ||
|
||
ENTRYPOINT ["/var/rapid/init", "--bootstrap", "/var/runtime/bootstrap", "--enable-msg-logs"] |