Skip to content

Commit

Permalink
Merge pull request #93 from hayd/deno-lamnda
Browse files Browse the repository at this point in the history
Add dockerfile for deno on aws lambda
  • Loading branch information
hayd committed Dec 16, 2020
2 parents 141444e + 2af65dc commit a80d1e3
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ jobs:
docker run -t ${{ matrix.kind }} run https://deno.land/std/examples/welcome.ts
docker run -t ${{ matrix.kind }} deno run https://deno.land/std/examples/welcome.ts
docker run -t ${{ matrix.kind }} echo 'test entry script'
lambda:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build Docker Image
run: |
cd lambda
docker build -f base.dockerfile -t hayd/deno-lambda .
docker build -f example.dockerfile -t example .
docker run -p=9000:8080 example &
sleep 5
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,19 @@ jobs:
dockerfile: alpine.dockerfile
cache: true
tags: "latest,${{ steps.get_version.outputs.VERSION }}"
build_deno_lambda:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Publish Deno Lambda
uses: elgohr/Publish-Docker-Github-Action@2.14
with:
name: "hayd/deno-lambda"
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: lambda/base.dockerfile
cache: true
tags: "latest,${{ steps.get_version.outputs.VERSION }}"
18 changes: 18 additions & 0 deletions lambda/base.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM public.ecr.aws/lambda/provided:al2

ENV BOOTSTRAP_VERSION=1.6.0
ENV DENO_VERSION=1.6.1

ENV DENO_DIR=/tmp/deno_dir
ENV DENO_INSTALL_ROOT=/usr/local

RUN yum install -y unzip \
&& curl -fsSL https://github.com/denoland/deno/releases/download/v${DENO_VERSION}/deno-x86_64-unknown-linux-gnu.zip \
--output deno.zip \
&& unzip -qq deno.zip \
&& rm deno.zip \
&& chmod 777 deno \
&& mv deno /bin/deno \
&& curl -fsSL https://deno.land/x/lambda@${BOOTSTRAP_VERSION}/bootstrap \
--out ${LAMBDA_RUNTIME_DIR}/bootstrap \
&& chmod 777 ${LAMBDA_RUNTIME_DIR}/bootstrap
7 changes: 7 additions & 0 deletions lambda/example.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM hayd/deno-lambda

COPY hello.ts .
RUN deno cache hello.ts


CMD ["hello.handler"]
16 changes: 16 additions & 0 deletions lambda/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context
} from "https://deno.land/x/lambda/mod.ts";

export async function handler(
event: APIGatewayProxyEvent,
context: Context,
): Promise<APIGatewayProxyResult> {
return {
statusCode: 200,
headers: { "content-type": "text/html;charset=utf8" },
body: `Welcome to deno`,
};
}

0 comments on commit a80d1e3

Please sign in to comment.