Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
cleaned out ipunkt related example data from all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Speckmaier committed Jun 2, 2016
1 parent e0b9030 commit 3fd73da
Show file tree
Hide file tree
Showing 13 changed files with 824 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM busybox
ADD . /var/www/laravel
VOLUME /var/www/laravel
ADD nginx-conf/laravel.conf.tpl /etc/nginx/conf.template.d/
VOLUME /etc/nginx/conf.template.d
RUN sh -c 'if [ -f "/var/www/laravel/docker-prepare.sh" ] ; then sh /var/www/laravel/docker-prepare.sh ; fi'
CMD /bin/dc
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# rancherize
Rancherize your development workflow

## Features
- Start a development webserver for your local development environment
- Build and publish a new docker image
- Deploy your last published version to a rancher stack
- Perform a rolling upgrade in rancher to your last published version

## TODO
- Setup wizard for easy project setup
- Setup wizard for easy environment setup
13 changes: 13 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "ipunkt/rancherize",
"description": "Rancherize your development workflow",
"license": "MIT",
"authors": [
{
"name": "Sven Speckmaier",
"email": "sps@ipunkt.biz"
}
],
"bin": ["rancherize"],
"require": {}
}
28 changes: 28 additions & 0 deletions config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# The docker-compose project name
PROJECT_NAME=testproject



#
# Dockerhub Configuration
#
# The docker image will be published to
# DOCKER_REPOSITORY_USER/DOCKER_REPOSITORY_NAME:PROJECT_PREFIX$VERSION
#

# The docker username to which the image should be published
DOCKER_REPOSITORY_USER=johndoe

# The docker
DOCKER_REPOSITORY_NAME=test

# The docker tag prefix. Will be added in front of all docker tags when building
# or commiting
PROJECT_PREFIX=testproject_

#
# Rancher Configuration
#

# The rancher service name to use. Will be suffixed by -VERSION
SERVICE_NAME=AppWebserver
45 changes: 45 additions & 0 deletions docker-compose.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Webserver:
restart: always
ports:
- 8080:80
tty: true
image: ipunktbs/laravel-nginx:1.9.7_php7_v5
links:
- Database:database-master
volumes:
- #CODE_DIRECTORY#:/var/www/laravel
environment:
DATABASE_NAME: db
DATABASE_USER: user
DATABASE_PASSWORD: pw
DB_HOST: database-master
DB_DATABASE: db
DB_USERNAME: user
DB_PASSWORD: pw
SERVER_URL: http.test.local
Database:
restart: always
tty: true
image: ipunktbs/mysql-master:v1
stdin_open: true
volumes_from:
- Data-DBMaster
labels:
io.rancher.sidekicks: Data-Database
ports:
- 3306:3306/tcp
environment:
MYSQL_ROOT_PASSWORD: cookies
REPLICATION_USER: replicationuser
REPLICATION_PASSWORD: nothing
DATABASE: db
USER: suer
PASSWORD: pw
Data-Database:
tty: true
command:
- cat
image: ubuntu:14.04
stdin_open: true
volumes:
- /var/lib/mysql
2 changes: 2 additions & 0 deletions example-environment/scale.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AppWebserver-%VERSION%:
scale: 1
22 changes: 22 additions & 0 deletions example-environment/service.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
AppWebserver-%VERSION%:
restart: always
tty: true
image: ipunktbs/laravel-nginx:1.9.7_php7_v5
external_links:
- mysql/DB-Master:database-master
labels:
io.rancher.sidekicks: App-%VERSION%
volumes_from:
- App-%VERSION%
environment:
DATABASE_NAME: db
DATABASE_USER: user
DATABASE_PASSWORD: password
DB_HOST: database-master
DB_DATABASE: db
DB_USERNAME: user
DB_PASSWORD: passowrd
App-%VERSION%:
image: user/package:%VERSION%
command: /bin/dc
stdin_open: true
67 changes: 67 additions & 0 deletions filter_scale_larger_zero.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/php

<?PHP

function parseYaml($file) {
$fileContents = file_get_contents($file);
$data = yaml_parse($fileContents);
return $data;
}

function filterScale($input, $smallerThan = null) {

if($smallerThan === null)
$smallerThan = 1;

$containers = [];
foreach($input as $containerName => $containerData) {
if ( !array_key_exists('scale', $containerData))
continue;

$scale = intval($containerData['scale']);
if( $scale < $smallerThan )
continue;

$containers[$containerName] = $containerData;
}

return $containers;
}

function filterByRegex($input, $regex) {
$filteredContainers = [];

foreach($input as $containerName => $containerData) {
$match = preg_match('~'.$regex.'~', $containerName);
if( $match === false )
throw new InvalidArgumentException( "Beim matchen der Regex '$regex' ist ein Fehler aufgetreten." );

if( $match == 0 )
continue;

$filteredContainers[$containerName] = $containerData;
}

return $filteredContainers;
}

$file = 'rancher-compose.yml';
$regex = $argv[1];

$data = parseYaml($file);
$containers = filterScale($data);

if( ! empty($regex) ) {

try {
$filteredContainers = filterByRegex($containers, $regex);
} catch(InvalidArgumentException $e) {
echo $e->getMessage();
exit(1);
}
echo implode("\n", array_keys($filteredContainers) );
exit(0);

}

echo implode("\n", array_keys($containers) );
74 changes: 74 additions & 0 deletions nginx-conf/laravel.conf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
server {
listen 80 default_server;
listen 81 default_server http2 proxy_protocol;
listen [::]:80 default_server ipv6only=on;
root /var/www/laravel/public;
index index.php index.html index.htm;
server_tokens off;
error_log /var/log/nginx/error.log debug;
rewrite_log on;
server_name <SERVER_URL>;
### HTTPS Rewrite
#
# Der rewrite hier ist etwas komplizierter, damit die Unittests funktionieren
# Grundrewrite: Wenn am Loadbalancer nicht mit https angefagt wird dann leite auf https weiter
# Problem: Unittests haben keinen Loadbalancer zwischen sich und dem Server
# Lösung: Lokale Adressen werden vom rewrite ausgenommen
# Achtung: Zugriffe in der lokalen dev Umgebung zählen als von außen kommend, weil diese von der `öffentlichen` Container-
# Adresse reinkommen.
#
# Grundstatus: Request kommt von außen
set $test "REMOTE";
# Bedingung: Wenn die ipv4 localhost Adresse mitgegeben wurde dann haben wir einen lokalen request
if ($remote_addr = "127.0.0.1") {
set $test "LOCAL";
}

# Bedingung: Wenn die ipv6 localhost Adresse mitgegeben wurde dann haben wir einen lokalen request
if ($remote_addr = "::1") {
set $test "LOCAL";
}


# Bedingung: Wenn das Anfordernde Protokol am Loadbalancer nicht https ist
if ($http_x_forwarded_proto != "https") {
set $test "${test}PROTO";
}

# Bedingung: Wenn der Request am Loadbalancer nicht mit https ankam UND es sich nicht um einen lokalen request handelt
# leite um auf https.
# Die Abfrage auf den zusammengesetzten String ist ein pseudoe AND. Nginx unterstützt keine und/oder in if Bedingungen
if ($test = REMOTEPROTO) {
rewrite ^/(.*)$ https://$host/$1 permanent;
}
### HTTPS Rewrite Ende

if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}

Loading

0 comments on commit 3fd73da

Please sign in to comment.