Skip to content

Commit 05525cf

Browse files
committed
Prep version configuration for releases
Add circle ci release configuration Add environment variable config for port number to support config when running in container Add Dockerfile to release image
1 parent d44a9cd commit 05525cf

File tree

5 files changed

+98
-6
lines changed

5 files changed

+98
-6
lines changed

.circleci/config.yml

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
version: 2
22
jobs:
33
build:
4-
54
working_directory: ~/aws-lambda-runtime-local
6-
75
docker:
86
- image: circleci/openjdk:11-jdk
97

@@ -20,4 +18,88 @@ jobs:
2018
paths:
2119
- ~/.gradle
2220
key: deps-{{ checksum "build.gradle.kts" }}
23-
- run: gradle test
21+
- run: gradle test
22+
- store_artifacts:
23+
path: build/libs
24+
- persist_to_workspace:
25+
root: .
26+
paths:
27+
- build/libs
28+
- Dockerfile
29+
30+
github-release:
31+
working_directory: ~/aws-lambda-runtime-local
32+
docker:
33+
- image: cibuilds/github:0.10
34+
steps:
35+
- attach_workspace:
36+
at: .
37+
- run:
38+
name: "Publish Release on GitHub"
39+
command: |
40+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} aws-lambda-runtime-local-$VERSION.jar
41+
42+
docker-publish:
43+
working_directory: ~/aws-lambda-runtime-local
44+
docker:
45+
- image: docker:18.06.1-ce-git
46+
steps:
47+
- setup_remote_docker
48+
- attach_workspace:
49+
at: .
50+
- restore_cache:
51+
keys:
52+
- v1-{{ .Branch }}
53+
paths:
54+
- /caches/aws-lambda-runtime-local.tar
55+
- run:
56+
name: Load Docker image layer cache
57+
command: |
58+
set +o pipefail
59+
docker load -i /caches/aws-lambda-runtime-local.tar | true
60+
- run:
61+
name: Build application Docker image
62+
command: |
63+
docker build --cache-from=aws-lambda-runtime-local -t c1phr/aws-lambda-runtime-local .
64+
- deploy:
65+
name: Publish Docker Image to Docker Hub
66+
command: |
67+
if [ "${CIRCLE_BRANCH}" == "master" ]; then
68+
echo "$DOCKERHUB_PASSWORD" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
69+
IMAGE_TAG="${CIRCLE_TAG}"
70+
IMAGE_NAME="c1phr/aws-lambda-runtime-local"
71+
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
72+
docker push $IMAGE_NAME:latest
73+
docker push $IMAGE_NAME:$IMAGE_TAG
74+
fi
75+
- run:
76+
name: Save Docker image layer cache
77+
command: |
78+
mkdir -p /caches
79+
docker save -o /caches/aws-lambda-runtime-local.tar c1phr/aws-lambda-runtime-local
80+
- save_cache:
81+
key: v1-{{ .Branch }}-{{ epoch }}
82+
paths:
83+
- /caches/aws-lambda-runtime-local.tar
84+
85+
workflows:
86+
version: 2
87+
main:
88+
jobs:
89+
- build
90+
- github-release:
91+
requires:
92+
- build
93+
filters:
94+
branches:
95+
ignore: /.*/
96+
tags:
97+
only: /^\d+\.\d+\.\d+$/
98+
- docker-publish:
99+
requires:
100+
- build
101+
filters:
102+
branches:
103+
ignore: /.*/
104+
tags:
105+
only: /^\d+\.\d+\.\d+$/

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM adoptopenjdk/openjdk11:alpine-jre
2+
ADD aws-lambda-runtime-local-*.jar aws-lambda-runtime-local.jar
3+
ENTRYPOINT java -jar aws-lambda-runtime-local.jar

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# aws-lambda-runtime-local
1+
# aws-lambda-runtime-local [ ![](https://img.shields.io/circleci/project/github/rdbatch02/lambda-runtime-kotlin-native/master.svg?style=flat) ](https://circleci.com/gh/rdbatch02/aws-lambda-runtime-local)
22
AWS Lambda Runtime API for local testing of custom runtimes
33

44
This project runs an HTTP API that is intended to emulate the [AWS Lambda Runtime Interface](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html) to enable local testing of custom runtimes.

build.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
23

34
val kotlinVersion = "1.3.31"
45
val http4kVersion = "3.140.0"
56

67
plugins {
78
kotlin("jvm") version "1.3.31"
89
id("com.github.johnrengelman.shadow") version "5.0.0"
10+
id("com.palantir.git-version") version "0.12.0-rc2"
911
}
12+
val gitVersion: groovy.lang.Closure<*> by extra
1013

1114
group = "com.batchofcode"
12-
version = "0.1-SNAPSHOT"
15+
version = gitVersion.call()
1316
val artifactId = "aws-lambda-runtime-local"
1417

1518
repositories {
@@ -32,6 +35,10 @@ tasks.withType<KotlinCompile> {
3235
kotlinOptions.jvmTarget = "11"
3336
}
3437

38+
tasks.withType<ShadowJar> {
39+
classifier = ""
40+
}
41+
3542
val jar by tasks.getting(Jar::class) {
3643
manifest {
3744
attributes["Main-Class"] = "com.batchofcode.runtimelocal.handler.RootHandlerKt"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.batchofcode.runtimelocal.config
22

33
object EnvConfig {
4-
val port = System.getProperty("port")?.toInt() ?: 9000
4+
val port = System.getProperty("runtime.port")?.toInt() ?: System.getenv("RUNTIME_PORT")?.toInt() ?: 9000
55
}

0 commit comments

Comments
 (0)