diff --git a/Vagrantfile b/Vagrantfile index 4a27ae94..9eb0aaa5 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,6 +10,7 @@ Vagrant.configure(2) do |config| # webserver config.vm.network "forwarded_port", guest: 80, host: 80 config.vm.network "forwarded_port", guest: 8080, host: 8080 + config.vm.network "forwarded_port", guest: 8081, host: 8081 # postgres config.vm.network "forwarded_port", guest: 5432, host: 5432 # elastic search diff --git a/api/docker/Dockerfile b/api/docker/Dockerfile new file mode 100644 index 00000000..52bbd3e3 --- /dev/null +++ b/api/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM spira/docker-nginx-php:latest + +MAINTAINER "Zak Henry" + +ADD . /data \ No newline at end of file diff --git a/api/docker/config/vhosts/spira-api.conf b/api/docker/config/vhosts/spira-api.conf new file mode 100644 index 00000000..3692d854 --- /dev/null +++ b/api/docker/config/vhosts/spira-api.conf @@ -0,0 +1,33 @@ +server { + client_max_body_size 20M; + listen 8080; + + root /data/public; + index index.php index.html index.htm; + + access_log /var/log/nginx/access-api.log; + error_log /var/log/nginx/error-api.log warn; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + +# location /api/ { +# proxy_pass http://127.0.0.1:8080/; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# proxy_set_header X-Forwarded-for $remote_addr; +# port_in_redirect off; +# proxy_connect_timeout 300; +# } + + location ~ \.php$ { + include fastcgi.conf; + fastcgi_pass fastgci_backend; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + location ~ /\.ht { + deny all; + } +} \ No newline at end of file diff --git a/app/docker/Dockerfile b/app/docker/Dockerfile new file mode 100644 index 00000000..52bbd3e3 --- /dev/null +++ b/app/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM spira/docker-nginx-php:latest + +MAINTAINER "Zak Henry" + +ADD . /data \ No newline at end of file diff --git a/app/docker/config/vhosts/spira-app.conf b/app/docker/config/vhosts/spira-app.conf new file mode 100644 index 00000000..aad3de56 --- /dev/null +++ b/app/docker/config/vhosts/spira-app.conf @@ -0,0 +1,40 @@ +server { + client_max_body_size 20M; + listen 8081; + + # rewrite ^/forum(/.*)$ http://%HOSTNAME_FORUM%$1 permanent; + + + access_log /var/log/nginx/access-app.log; + error_log /var/log/nginx/error-app.log warn; + + # allow the source files to be read by the browser for sourcemapping + location /data/src { + root /; + try_files $uri $uri/ =404; + } + + location /data/bower_components { + root /; + try_files $uri $uri/ =404; + } + + location / { + root /data/build; + index index.html; + try_files $uri $uri/ /index.html =404; + } + +# location /auth/social/ { +# proxy_pass http://127.0.0.1:8080/auth/social/; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# proxy_set_header X-Forwarded-for $remote_addr; +# port_in_redirect off; +# proxy_connect_timeout 300; +# } + + location ~ /\.ht { + deny all; + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 9846f430..904b13eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,23 @@ -data: +lbhaproxy: extends: file: ./docker/common-services.yml - service: datavolume + service: lbhaproxy + links: + - api + - app + - mailcatcher env_file: - ./docker/.local.env -logviewer: - extends: - file: ./docker/common-services.yml - service: logviewer - volumes_from: - - data - env_file: - - ./docker/.local.env +#logviewer: +# extends: +# file: ./docker/common-services.yml +# service: logviewer +# volumes_from: +# - data +# env_file: +# - ./docker/.local.env database: extends: @@ -34,21 +38,21 @@ vanilladatabase: - ./docker/.local.env cache: - ports: - - "6379:6379" extends: file: ./docker/common-services.yml service: cache + ports: + - "6379:6379" env_file: - ./docker/.local.env elasticsearch: - ports: - - "9200:9200" - - "9300:9300" extends: file: ./docker/common-services.yml service: elasticsearch + ports: + - "9200:9200" + - "9300:9300" env_file: - ./docker/.local.env @@ -59,73 +63,68 @@ queue: env_file: - ./docker/.local.env -queuerunner: +api: extends: file: ./docker/common-services.yml - service: queuerunner + service: api links: - - mailcatcher:mailcatcher - - queue:queue - - cache:cache - - database:database - - web:web - volumes_from: - - data + - mailcatcher + - queue + - cache + - database env_file: - ./docker/.local.env + environment: + - VIRTUAL_HOST=local.api.spira.io, local.spira.io/api/* + - NGINX_VHOSTS=/data/docker/config/vhosts/*.conf + - EXCLUDE_PORTS=9000 -mailcatcher: +app: extends: file: ./docker/common-services.yml - service: mailcatcher + service: app env_file: - ./docker/.local.env + environment: + - VIRTUAL_HOST=local.spira.io + - NGINX_VHOSTS=/data/docker/config/vhosts/*.conf + - EXCLUDE_PORTS=9000 -php: +queuerunner: extends: file: ./docker/common-services.yml - service: php + service: queuerunner links: - - database:database - - vanilladatabase:vanilladatabase - - cache:cache - - queue:queue - - mailcatcher:mailcatcher - - elasticsearch:elasticsearch + - mailcatcher + - queue + - cache + - database volumes_from: - - data + - api env_file: - ./docker/.local.env -web: +mailcatcher: extends: file: ./docker/common-services.yml - service: web - ports: - - "80:80" - - "8080:8080" - links: - - php:php - - logviewer:logviewer - - mailcatcher:mailcatcher - volumes_from: - - data - env_file: ./docker/.local.env + service: mailcatcher + env_file: + - ./docker/.local.env + environment: + - VIRTUAL_HOST=local.mailcatcher.spira.io + - EXCLUDE_PORTS=1025 devtools: extends: file: ./docker/common-services.yml service: devtools links: - - web:web - mailcatcher:mailcatcher - database:database - vanilladatabase:vanilladatabase - cache:cache - queue:queue - elasticsearch:elasticsearch - volumes_from: - - data volumes: - /cache:/cache env_file: diff --git a/docker/.local.env b/docker/.local.env index eb15307c..77b0ea46 100644 --- a/docker/.local.env +++ b/docker/.local.env @@ -52,4 +52,8 @@ MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION= MAIL_FROM_ADDRESS=api@local.api.spira.io -MAIL_FROM_NAME=Local Spira API \ No newline at end of file +MAIL_FROM_NAME=Local Spira API + +#haproxy +MODE=tcp +STATS_AUTH=spira:password \ No newline at end of file diff --git a/docker/common-services.yml b/docker/common-services.yml index a8abfbde..b4437edd 100644 --- a/docker/common-services.yml +++ b/docker/common-services.yml @@ -1,14 +1,23 @@ # This common-services.yml definition holds all the image definitions and environment linking for the images. # It is intended to use the docker-compose extends functionality to use these definitions to build a docker-compose file +lbhaproxy: + image: 'tutum/haproxy:0.2.4.1' + environment: + - MODE=tcp + - 'STATS_AUTH=spira:' + ports: + - '80:80' + - '1936:1936' + datavolume: image: spira/docker-data volumes: - /data:/data privileged: true -logviewer: - image: spira/docker-clarity +#logviewer: +# image: spira/docker-clarity database: image: postgres:9.4 @@ -41,20 +50,48 @@ php: - .secret.env privileged: true -web: - image: spira/docker-nginx +#web: +# image: spira/docker-nginx +# expose: +# - "80" +# - "8080" +# - "8008" +# env_file: +# - .common.env +# privileged: true + +api: + image: spira/docker-nginx-php + env_file: + - .common.env + - .secret.env + volumes: + - ../api:/data expose: - - "80" - - "8080" - - "8008" + - "8080" + ports: + - "8080:8080" + privileged: true + +app: + image: spira/docker-nginx-php env_file: - .common.env + - .secret.env + volumes: + - ../app:/data + expose: + - "8081" + ports: + - "8081:8081" privileged: true devtools: image: spira/docker-dev-tools working_dir: /data privileged: true + volumes: + - ../:/data env_file: - .common.env - .secret.env diff --git a/vhosts/nginx/dev/spira-app.conf b/vhosts/nginx/dev/spira-app.conf index a44e8d15..11c04931 100644 --- a/vhosts/nginx/dev/spira-app.conf +++ b/vhosts/nginx/dev/spira-app.conf @@ -1,7 +1,6 @@ server { client_max_body_size 20M; listen 80; - server_name %HOSTNAME_BASE%; server_name %HOSTNAME_APP%; rewrite ^/forum(/.*)$ http://%HOSTNAME_FORUM%$1 permanent;