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:
parent
28d33adce7
commit
21a0aaa6bc
6 changed files with 66 additions and 51 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
.env
|
||||
db_data
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ Hosting setup for demos.tf
|
|||
Create a `.env` file with the following values:
|
||||
|
||||
- HOST
|
||||
- PORT
|
||||
- HTTPS_PORT
|
||||
- EMAIL
|
||||
- DB_PASSWORD
|
||||
|
||||
Start the containers:
|
||||
|
||||
|
|
|
|||
25
api.tmpl
Normal file
25
api.tmpl
Normal 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
client_max_body_size 150m;
|
||||
|
||||
location = /upload {
|
||||
limit_except GET HEAD {
|
||||
proxy_pass http://upload.demos.tf;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,52 +2,45 @@ version: '2'
|
|||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
image: demostf/demos.tf
|
||||
container_name: nginx
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "${PORT}:80"
|
||||
- "${HTTPS_PORT}:443"
|
||||
volumes:
|
||||
- "/etc/nginx/conf.d"
|
||||
- "/etc/nginx/vhost.d"
|
||||
- "/usr/share/nginx/html"
|
||||
- "certs:/etc/nginx/certs:ro"
|
||||
- "./api.tmpl:/etc/nginx/conf.d/api.tmpl"
|
||||
environment:
|
||||
- HOST=${HOST}
|
||||
networks:
|
||||
- proxy-tier
|
||||
nginx-gen:
|
||||
image: jwilder/docker-gen
|
||||
container_name: nginx-gen
|
||||
volumes:
|
||||
- "/var/run/docker.sock:/tmp/docker.sock:ro"
|
||||
- "./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
|
||||
depends_on:
|
||||
- api
|
||||
api:
|
||||
image: demostf/api
|
||||
container_name: api
|
||||
environment:
|
||||
- ENABLE_IPV6=true
|
||||
- DB_TYPE=pgsql
|
||||
- DB_HOST=db
|
||||
- DB_DATABASE=postgres
|
||||
- DB_USERNAME=postgres
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
networks:
|
||||
- proxy-tier
|
||||
letsencrypt-nginx-proxy-companion:
|
||||
image: jrcs/letsencrypt-nginx-proxy-companion
|
||||
container_name: letsencrypt-nginx-proxy-companion
|
||||
volumes_from:
|
||||
- nginx
|
||||
volumes:
|
||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||
- "certs:/etc/nginx/certs:rw"
|
||||
environment:
|
||||
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen
|
||||
- db-tier
|
||||
upload:
|
||||
image: nginx
|
||||
container_name: upload
|
||||
|
||||
demostf:
|
||||
image: demostf/demos.tf
|
||||
container_name: demostf
|
||||
db:
|
||||
image: demostf/db
|
||||
container_name: db
|
||||
environment:
|
||||
- VIRTUAL_HOST=${HOST}
|
||||
- LETSENCRYPT_HOST=${HOST}
|
||||
- LETSENCRYPT_EMAIL=${EMAIL}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
volumes:
|
||||
- "./db_data:/var/lib/postgresql/data"
|
||||
networks:
|
||||
- proxy-tier
|
||||
- db-tier
|
||||
|
||||
networks:
|
||||
proxy-tier:
|
||||
|
|
|
|||
20
nginx.tmpl
20
nginx.tmpl
|
|
@ -200,20 +200,20 @@ server {
|
|||
|
||||
location / {
|
||||
{{ if eq $proto "uwsgi" }}
|
||||
include uwsgi_params;
|
||||
uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||
include uwsgi_params;
|
||||
uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||
{{ else }}
|
||||
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
|
||||
{{ end }}
|
||||
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
|
||||
auth_basic "Restricted {{ $host }}";
|
||||
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
|
||||
auth_basic "Restricted {{ $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 }}
|
||||
{{ 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 }}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue