Skip to content

Commit

Permalink
Process to build the function natively inside docker
Browse files Browse the repository at this point in the history
  • Loading branch information
KensoDev committed May 19, 2017
1 parent fbc1124 commit c620039
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
lambda/releases/*
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ COPY setup.sh /setup.sh
RUN yum install -y gcc-c++ make
RUN chmod +x /setup.sh
RUN sh /setup.sh
RUN yum install -y nodejs
RUN yum install -y nodejs
RUN mkdir -p /build
RUN yum install -y zip
VOLUME /build
WORKDIR /build
8 changes: 8 additions & 0 deletions lambda/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set -e

function_name=image-resizer
d=`date +"%m-%d-%y-%H-%M-%S"`
release_dir=releases/$d
mkdir -p $release_dir
zip -r function.zip index.js package.json node_modules
mv function.zip $release_dir
9 changes: 1 addition & 8 deletions lambda/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ const AWS = require("aws-sdk");
const Sharp = require("sharp");

exports.handler = (event, context, callback) => {
const local = true;

const s3 = new AWS.S3({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
});
const s3 = new AWS.S3();

const bucketName = "creative-network-uploads";
let key = event.queryStringParameters.key;
Expand All @@ -20,8 +15,6 @@ exports.handler = (event, context, callback) => {
const imageName= m[5];
const extension = m[6];

console.log(key);

key = key.replace(extension, "png");

const originalKey = `${directory}/${imageId}/${imageName}.${extension}`
Expand Down

0 comments on commit c620039

Please sign in to comment.