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
13 changed files
with
157 additions
and
6 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
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 = '11' | ||
targetCompatibility = '11' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile ( | ||
'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.667' | ||
) | ||
} | ||
|
||
task buildZip(type: Zip) { | ||
from compileJava | ||
from processResources | ||
into('lib') { | ||
from configurations.runtime | ||
} | ||
} | ||
|
||
build.dependsOn buildZip | ||
|
||
// docker run --rm -v "$PWD":/app -w /app gradle:jdk11 gradle build |
66 changes: 66 additions & 0 deletions
66
base/dump-java11/src/main/java/org/lambci/lambda/DumpJava11.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,66 @@ | ||
package org.lambci.lambda; | ||
|
||
import java.io.File; | ||
import java.lang.management.ManagementFactory; | ||
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 DumpJava11 implements RequestHandler<Object, PutObjectResult> { | ||
|
||
@Override | ||
public PutObjectResult handleRequest(Object input, Context context) { | ||
String filename = "java11.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 { | ||
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(); | ||
if (process.exitValue() != 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); | ||
} | ||
} | ||
} |
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
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,17 @@ | ||
FROM lambci/lambda-base-2:build | ||
|
||
ENV PATH=/var/lang/bin:$PATH \ | ||
LD_LIBRARY_PATH=/var/lang/lib:$LD_LIBRARY_PATH \ | ||
AWS_EXECUTION_ENV=AWS_Lambda_java11 | ||
|
||
RUN rm -rf /var/runtime /var/lang /var/rapid && \ | ||
curl https://lambci.s3.amazonaws.com/fs/java11.tgz | tar -zx -C / && \ | ||
mkdir /usr/local/gradle && curl -L -o gradle.zip https://services.gradle.org/distributions/gradle-5.6-bin.zip && \ | ||
unzip -d /usr/local/gradle gradle.zip && rm gradle.zip && mkdir /usr/local/maven && \ | ||
curl -L http://mirror.metrocast.net/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz | \ | ||
tar -zx -C /usr/local/maven | ||
|
||
ENV PATH="/usr/local/gradle/gradle-5.6/bin:/usr/local/maven/apache-maven-3.6.2/bin:${PATH}" | ||
|
||
# Add these as a separate layer as they get updated frequently | ||
RUN pip install -U awscli boto3 aws-sam-cli==0.31.0 aws-lambda-builders==0.5.0 --no-cache-dir |
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,22 @@ | ||
FROM lambci/lambda-base | ||
|
||
RUN curl https://lambci.s3.amazonaws.com/fs/java11.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_java11 | ||
|
||
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"] | ||
|