Skip to content

Instantly share code, notes, and snippets.

View sfrancavilla's full-sized avatar

Stefano Francavilla sfrancavilla

  • Geowox
  • Dublin, Ireland
View GitHub Profile
@sfrancavilla
sfrancavilla / template.yaml
Last active April 16, 2020 06:35
Build and secure your API Gateway using SAM, Cognito, CloudFormation and CI/CD
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-api
Sample SAM Template for sam-api
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
@sfrancavilla
sfrancavilla / nginx.conf
Created May 13, 2019 21:58
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
# 1.Upstream used to define groups of servers, in this case the rails app, that can be referenced by the proxy_pass
upstream rails_app {
server app:3000;
}
# 2.Server part
server {
# 2.1.Listen to incoming connection on port 80
listen 80;
listen [::]:80;
@sfrancavilla
sfrancavilla / docker-compose.yml
Created May 13, 2019 18:47
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
version: '3'
services:
app:
# 1.Repository URI for our app image
image: XXXXXXXXXX.dkr.ecr.eu-west-1.amazonaws.com/ror-ecs-app
build:
context: .
dockerfile: ./docker/app/Dockerfile
web:
# 2.Repository URI for our web image
@sfrancavilla
sfrancavilla / docker-compose.yml
Created May 13, 2019 17:12
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
# 1.Specify the compose file format; we're using the last one.
# If you're curious, at https://docs.docker.com/compose/compose-file/compose-versioning/
# you can find an extensive description on the difference among versions
version: '3'
# 2.Specify the list of services that will be built. In our case, app (Ruby on Rails) and web (NGINX)
services:
app:
build:
# 2.1.Specify the root path
context: .
@sfrancavilla
sfrancavilla / nginx.conf
Created May 13, 2019 07:59
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
# 1.Upstream used to define groups of servers, in this case the rails app, that can be referenced by the proxy_pass
upstream rails_app {
server app:3000;
}
# 2.Server part
server {
# 2.1.Listen to incoming connection on port 80
listen 80;
listen [::]:80;
@sfrancavilla
sfrancavilla / start.sh
Created May 13, 2019 07:49
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
#!/bin/sh
envsubst '$RAILS_ROOT' < /tmp/app.conf > /etc/nginx/conf.d/default.conf
nginx -g "daemon off;"
@sfrancavilla
sfrancavilla / Dockerfile
Last active May 20, 2019 17:11
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
# 1.Retrieve the nginx base image
FROM nginx
# 2.Install some dependencies
RUN apt-get update -qq && apt-get -y install apache2-utils
# 3.Set env variable where NGINX should look for project files
ENV RAILS_ROOT /var/www/ror-ecs
# 4.Set working directory
@sfrancavilla
sfrancavilla / Dockerfile
Last active May 20, 2019 17:11
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
# 1.Retrieve the ruby image
FROM ruby:2.4.1
# 2.Install basic required libs
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# 3.Install bundler
RUN gem install bundler --version "1.15.3"
# 4.Set an environment variable for the Rails app root folder
@sfrancavilla
sfrancavilla / routes.rb
Created May 13, 2019 07:18
Deploy Ruby on Rails apps (+ NGINX) to ECS with Docker - Medium
Rails.application.routes.draw do
get 'welcome/index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'welcome#index'
end