Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
import * as cloud from "@pulumi/cloud";
// A bucket to store videos and thumbnails.
const bucket = new cloud.Bucket("bucket");
// A task which runs a containerized FFMPEG job to extract a thumbnail image.
const ffmpegThumbnailTask = new cloud.Task("ffmpegThumbTask", {
build: "./docker-ffmpeg-thumb",
memoryReservation: 512,
});
// When a new video is uploaded, run the FFMPEG task on the video file.
// Use the time index specified in the filename (e.g. cat_00-01.mp4 uses timestamp 00:01)
bucket.onPut("onNewVideo", async (bucketArgs) => {
console.log(`*** New video: file ${bucketArgs.key} was uploaded at ${bucketArgs.eventTime}.`);
const file = bucketArgs.key;
const thumbnailFile = file.substring(0, file.indexOf('_')) + '.jpg';
const framePos = file.substring(file.indexOf('_')+1, file.indexOf('.')).replace('-',':');
ffmpegThumbnailTask.run({
environment: {
"BUCKET": bucketArgs.id,
client.set(key, value, (err: any, v: any) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
});
};
}
}
let cache = new Cache("examples-mycache");
let helloTask = new cloud.Task("examples-hello-world", {
image: "hello-world",
memory: 20,
});
// build an anonymous image:
let builtService = new cloud.Service("examples-nginx2", {
containers: {
nginx: {
build: "./app",
memory: 128,
ports: [{ port: 80 }],
},
},
replicas: 2,
waitForSteadyState: false,
});