Skip to content

Instantly share code, notes, and snippets.

View crizstian's full-sized avatar

Cristian Ramirez crizstian

View GitHub Profile
#!/usr/bin/env bash
function setup-swarm {
# first we go to our docker folder
cd _docker_setup
echo '···························'
echo '·· setting up the swarm >>>> ··'
echo '···························'
#!/usr/bin/env bash
eval `docker-machine env manager1`
array=('./movies-service'
'./cinema-catalog-service'
'./booking-service'
'./payment-service'
'./notification-service'
)
@crizstian
crizstian / create-and-push-images.sh
Last active February 15, 2017 17:49
Example of an automated creation and pushing of docker images
#!/usr/bin/env bash
eval `docker-machine env manager1`
array=('./movies-service'
'./cinema-catalog-service'
'./booking-service'
'./payment-service'
'./notification-service'
)
#!/usr/bin/env bash
eval `docker-machine env manager1`
array=('./movies-service'
'./cinema-catalog-service'
'./booking-service'
'./payment-service'
'./notification-service'
)
@crizstian
crizstian / cinema.microservices.Dockerfile
Last active April 15, 2020 02:15
Example of Dockerfile for a nodejs app
# the first thing we specify in a Dockerfile is the base image.
# This is essentially bare bones alpine linux with node installed.
FROM node:7.5.0-alpine
# Creates a non-root-user.
RUN addgroup -S nupp && adduser -S -g nupp nupp
# Sets the HOME environment variable.
ENV HOME=/home/nupp
@crizstian
crizstian / create-swarm-cluster.sh
Last active August 21, 2018 04:51
Example of creating a swarm cluster
#!/bin/bash
# default parameters
DRIVER="virtualbox"
MANAGERS=1
WORKERS=2
DISK_SIZE="20000"
MEMORY="2048"
DOCKER_VERSION="https://github.com/boot2docker/boot2docker/releases/download/v1.13.0/boot2docker.iso"
ADDITIONAL_PARAMS=
@crizstian
crizstian / api-gateway-int-test.js
Last active February 13, 2017 05:07
Example of api-gateway super test
/* eslint-env mocha */
const supertest = require('supertest')
// we need this to accept self-signed-certificates in nodejs
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
process.env.NODE_TLS_ACCEPT_UNTRUSTED_CERTIFICATES_THIS_IS_INSECURE = '1'
describe('cinema-catalog-service', () => {
const api = supertest('https://localhost:8080')
it('returns a 200 for a known movies through api-gateway', (done) => {
#!/usr/bin/env bash
eval `docker-machine env manager1`
array=('./movies-service'
'./cinema-catalog-service'
'./booking-service'
'./payment-service'
'./notification-service'
)
'use strict'
const express = require('express')
const proxy = require('http-proxy-middleware')
const spdy = require('spdy')
const morgan = require('morgan')
const helmet = require('helmet')
const cors = require('cors')
const status = require('http-status')
const start = (container) => {
@crizstian
crizstian / api-gateway.docker.js
Last active February 14, 2017 14:50
Example of generating docker containers url routes for proxy configurations
'use strict'
const Docker = require('dockerode')
const discoverRoutes = (container) => {
return new Promise((resolve, reject) => {
// here we retrieve our dockerSettings
const dockerSettings = container.resolve('dockerSettings')
// we instatiate our docker object, that will communicate with our docker-machine
const docker = new Docker(dockerSettings)