1
0
Fork 0
mirror of https://github.com/demostf/setup synced 2026-06-04 00:54:07 +02:00

add api and DB

This commit is contained in:
Robin Appelman 2017-03-19 17:42:29 +01:00
commit 21a0aaa6bc
6 changed files with 66 additions and 51 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
.env .env
db_data

View file

@ -7,7 +7,10 @@ Hosting setup for demos.tf
Create a `.env` file with the following values: Create a `.env` file with the following values:
- HOST - HOST
- PORT
- HTTPS_PORT
- EMAIL - EMAIL
- DB_PASSWORD
Start the containers: Start the containers:

25
api.tmpl Normal file
View file

@ -0,0 +1,25 @@
server {
listen 80;
server_name api.${HOST};
root /usr/share/nginx/html;
client_max_body_size 150m;
index index.php;
try_files $uri /index.php?$query_string /index.php;
location ~ \.php$ {
fastcgi_pass api:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /app/public/index.php;
}
location = /upload {
fastcgi_pass api:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /app/public/upload.php;
}
}

View file

@ -1,7 +0,0 @@
client_max_body_size 150m;
location = /upload {
limit_except GET HEAD {
proxy_pass http://upload.demos.tf;
}
}

View file

@ -2,52 +2,45 @@ version: '2'
services: services:
nginx: nginx:
image: nginx image: demostf/demos.tf
container_name: nginx container_name: nginx
ports: ports:
- "80:80" - "${PORT}:80"
- "443:443" - "${HTTPS_PORT}:443"
volumes: volumes:
- "/etc/nginx/conf.d"
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "certs:/etc/nginx/certs:ro" - "certs:/etc/nginx/certs:ro"
- "./api.tmpl:/etc/nginx/conf.d/api.tmpl"
environment:
- HOST=${HOST}
networks: networks:
- proxy-tier - proxy-tier
nginx-gen: depends_on:
image: jwilder/docker-gen - api
container_name: nginx-gen api:
volumes: image: demostf/api
- "/var/run/docker.sock:/tmp/docker.sock:ro" container_name: api
- "./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
- "./demostf-nginx.conf:/etc/nginx/vhost.d/${HOST}"
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
environment: environment:
- ENABLE_IPV6=true - DB_TYPE=pgsql
- DB_HOST=db
- DB_DATABASE=postgres
- DB_USERNAME=postgres
- DB_PASSWORD=${DB_PASSWORD}
networks: networks:
- proxy-tier - proxy-tier
letsencrypt-nginx-proxy-companion: - db-tier
image: jrcs/letsencrypt-nginx-proxy-companion upload:
container_name: letsencrypt-nginx-proxy-companion image: nginx
volumes_from: container_name: upload
- nginx
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "certs:/etc/nginx/certs:rw"
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen
demostf: db:
image: demostf/demos.tf image: demostf/db
container_name: demostf container_name: db
environment: environment:
- VIRTUAL_HOST=${HOST} - POSTGRES_PASSWORD=${DB_PASSWORD}
- LETSENCRYPT_HOST=${HOST} volumes:
- LETSENCRYPT_EMAIL=${EMAIL} - "./db_data:/var/lib/postgresql/data"
networks: networks:
- proxy-tier - db-tier
networks: networks:
proxy-tier: proxy-tier:

View file

@ -200,20 +200,20 @@ server {
location / { location / {
{{ if eq $proto "uwsgi" }} {{ if eq $proto "uwsgi" }}
include uwsgi_params; include uwsgi_params;
uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
{{ else }} {{ else }}
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
{{ end }} {{ end }}
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
auth_basic "Restricted {{ $host }}"; auth_basic "Restricted {{ $host }}";
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }}; auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
{{ end }}
{{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}
include /etc/nginx/vhost.d/default_location;
{{ end }} {{ end }}
{{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}
include /etc/nginx/vhost.d/default_location;
{{ end }}
} }
} }