Skip to content

Instantly share code, notes, and snippets.

View li0nel's full-sized avatar

Lionel Martin li0nel

View GitHub Profile
# Use the official lightweight Node.js 12 image.
# https://hub.docker.com/_/node
FROM node:12-slim
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available).
# Copying this first prevents re-running npm install on every code change.
@li0nel
li0nel / gist:1e19cc2adae60fe42377a7c8ad33624b
Created November 4, 2018 13:22
tf-elasticbeanstalk-laravel
option_settings:
"aws:elasticbeanstalk:container:php:phpini":
document_root: /public
memory_limit: 512M
"aws:elasticbeanstalk:sqsd":
HttpPath: /worker/queue
"aws:elasticbeanstalk:application:environment":
APP_ENV: production
APP_KEY: base64:44cyzPQ+pYFpDz6VLgH3G9jRGXOmTvQe7mUq/PAqDWU=
DB_HOST: testdb.cvrp0yapqs3p.us-east-1.rds.amazonaws.com
@li0nel
li0nel / outputs.tf
Created July 13, 2018 10:33
Outputs
output "cloudfront_url" {
value = "${module.cloudfront-image-compression.cloudfront_url}"
}
output "bucket" {
value = "${module.cloudfront-image-compression.bucket}"
}
@li0nel
li0nel / variables.tf
Created July 13, 2018 10:33
Variables
variable "stack_name" {
type = "string"
}
variable "aws_region" {
type = "string"
}
variable "aws_profile" {
type = "string"
aws_profile = "default"
aws_region = "eu-west-2"
stack_name = "images"
domain = "getlionel.com"
subdomain = "images"
@li0nel
li0nel / master.tf
Last active July 13, 2018 10:32
example/master.tf
provider "aws" {
region = "${var.aws_region}"
profile = "${var.aws_profile}"
version = "~> 1.9"
}
provider "aws" {
region = "us-east-1"
profile = "${var.aws_profile}"
alias = "us-east-1"
@li0nel
li0nel / index.js
Last active July 13, 2018 09:25
Lambda@Edge image compression
const querystring = require('querystring')
const http = require('http')
const Sharp = require('sharp')
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request
console.log(request.uri)
if (request.uri === '/favicon.ico') {
@li0nel
li0nel / supportsWebp.js
Created July 12, 2018 14:28
supportsWebp.js
var supportsWebp = async function() {
if (!self.createImageBitmap) return false;
const webpData = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
const blob = await fetch(webpData).then(r => r.blob());
return createImageBitmap(blob).then(() => true, () => false);
}
@li0nel
li0nel / certbot
Created July 12, 2018 08:03
Execute Certbot
# Use Let's Encrypt certbot to order a free certificate
certbot certonly --non-interactive --manual \
--manual-auth-hook "./auth-hook.sh UPSERT your_domain.com" \
--manual-cleanup-hook "./auth-hook.sh DELETE your_domain.com" \
--preferred-challenge dns \
--config-dir "./letsencrypt" \
--work-dir "./letsencrypt" \
--logs-dir "./letsencrypt" \
--agree-tos \
--manual-public-ip-logging-ok \
@li0nel
li0nel / auth-hook.sh
Last active November 18, 2019 06:06
Creating our Let's Encrypt hook script
aws route53 wait resource-record-sets-changed --id \
$(aws route53 change-resource-record-sets --hosted-zone-id \
"$(aws route53 list-hosted-zones-by-name --dns-name $2. \
--query HostedZones[0].Id --output text)" \
--query ChangeInfo.Id \
--output text \
--change-batch "{ \
\"Changes\": [{ \
\"Action\": \"$1\", \
\"ResourceRecordSet\": { \