Skip to content

Instantly share code, notes, and snippets.

View mlabouardy's full-sized avatar
☁️
Subscribe to my newsletter ➡️ https://devopsbulletin.com

LABOUARDY Mohamed mlabouardy

☁️
Subscribe to my newsletter ➡️ https://devopsbulletin.com
View GitHub Profile
@mlabouardy
mlabouardy / before_start.sh
Created October 21, 2017 22:06
Install apache server
#!/bin/sh
yum update
yum install -y httpd
service httpd start
@mlabouardy
mlabouardy / after_start.sh
Created October 21, 2017 22:07
Restart apache server
#!/bin/sh
service httpd restart
@mlabouardy
mlabouardy / transcoder.js
Created October 21, 2017 22:12
Convert Videos to MP3 using AWS Transcoder
'use strict';
var AWS = require('aws-sdk'),
transcoder = new AWS.ElasticTranscoder({
apiVersion: '2012-09-25',
region: 'us-east-1'
});
exports.handler = (event, context, callback) => {
let fileName = event.Records[0].s3.object.key;
@mlabouardy
mlabouardy / server.js
Created October 22, 2017 11:23
Simple NodeJS app with MySQL as storage backend
var MySQL = require('mysql'),
express = require('express'),
app = express();
var connection = MySQL.createConnection({
host : process.env.MYSQL_HOST || 'localhost',
user : process.env.MYSQL_USER || '',
password : process.env.MYSQL_PASSWORD || ''
});
@mlabouardy
mlabouardy / Dockerfile
Created October 22, 2017 11:24
Dockerfile to build a NodeJS app
FROM node:8.7.0
MAINTAINER mlabouardy <[email protected]>
WORKDIR /app
RUN npm install mysql express
COPY server.js .
EXPOSE 3000
@mlabouardy
mlabouardy / docker-compose.yml
Created October 22, 2017 11:25
Compose to deploy a NodeJS & MySQL stack
version: "3.0"
services:
mysql:
image: mysql:5.6
environment:
- MYSQL_ROOT_PASSWORD=root
networks:
- db-net
@mlabouardy
mlabouardy / Dockerfile
Created October 22, 2017 11:26
Prevent race conditions with Dockernize
FROM node:8.7.0
MAINTAINER mlabouardy <[email protected]>
RUN apt-get update && apt-get install -y wget
ENV DOCKERIZE_VERSION v0.5.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
@mlabouardy
mlabouardy / handler.go
Created October 24, 2017 09:59
9Gag Function Serverless
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"github.com/mlabouardy/9gag"
@mlabouardy
mlabouardy / Dockerfile
Created October 24, 2017 09:59
Build Serverless Go app
FROM golang:1.9.1 AS builder
MAINTAINER mlabouardy <[email protected]>
WORKDIR /go/src/github.com/mlabouardy/Memes9Gag
RUN go get -d -v github.com/mlabouardy/9gag
COPY handler.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin
@mlabouardy
mlabouardy / stack.yml
Created October 24, 2017 10:00
Deploy 9Gag Serverless function
provider:
name: faas
gateway: http://localhost:8080
functions:
memes-9gag:
lang: Dockerfile
handler: ./function
image: mlabouardy/memes-9gag