migrate to caddy server
This commit is contained in:
parent
aa4b5b887e
commit
54b5c9ef2a
|
@ -18,6 +18,7 @@ The map of the fediverse that you always wanted.
|
||||||
- `docker-compose build`
|
- `docker-compose build`
|
||||||
- `docker-compose up -d django`
|
- `docker-compose up -d django`
|
||||||
- if you don't specify `django`, it'll also start `gephi` which should only be run as a regular one-off job
|
- if you don't specify `django`, it'll also start `gephi` which should only be run as a regular one-off job
|
||||||
|
- to run in production, run `caddy` rather than `django`
|
||||||
### Frontend
|
### Frontend
|
||||||
- `cd frontend && yarn install`
|
- `cd frontend && yarn install`
|
||||||
- `yarn start`
|
- `yarn start`
|
||||||
|
|
|
@ -2,7 +2,7 @@ from .base import *
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['api.fediverse.space']
|
ALLOWED_HOSTS = ['backend.fediverse.space']
|
||||||
|
|
||||||
CORS_ORIGIN_WHITELIST = [
|
CORS_ORIGIN_WHITELIST = [
|
||||||
'fediverse.space',
|
'fediverse.space',
|
||||||
|
|
|
@ -13,9 +13,9 @@ do
|
||||||
done
|
done
|
||||||
>&2 echo "Postgres is up"
|
>&2 echo "Postgres is up"
|
||||||
|
|
||||||
|
python manage.py collectstatic --noinput
|
||||||
python manage.py migrate --noinput
|
python manage.py migrate --noinput
|
||||||
|
|
||||||
|
|
||||||
if [[ $ENVIRONMENT == "development" ]]
|
if [[ $ENVIRONMENT == "development" ]]
|
||||||
then
|
then
|
||||||
>&2 echo "Running Django server on port 8000 for development"
|
>&2 echo "Running Django server on port 8000 for development"
|
||||||
|
|
11
config/Caddyfile
Normal file
11
config/Caddyfile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
backend.fediverse.space {
|
||||||
|
tls tao@btao.org
|
||||||
|
gzip
|
||||||
|
|
||||||
|
root /srv
|
||||||
|
proxy / django:8000 {
|
||||||
|
transparent
|
||||||
|
except /static
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
# range.
|
# range.
|
||||||
#
|
#
|
||||||
|
|
||||||
bind = ['unix:/var/gunicorn/.sock', ':8000']
|
bind = [':8000']
|
||||||
|
|
||||||
#
|
#
|
||||||
# Worker processes
|
# Worker processes
|
||||||
|
|
|
@ -1,68 +1,49 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
nginx:
|
|
||||||
image: jwilder/nginx-proxy:alpine
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
- "443:443"
|
|
||||||
labels:
|
|
||||||
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
|
|
||||||
volumes:
|
|
||||||
- gunicorn-socket:/var/gunicorn # to talk to Django
|
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro # for nginx-proxy
|
|
||||||
- conf:/etc/nginx/conf.d
|
|
||||||
- vhost:/etc/nginx/vhost.d
|
|
||||||
- html:/usr/share/nginx/html
|
|
||||||
- certs:/etc/nginx/certs:ro
|
|
||||||
networks:
|
|
||||||
- nginx_network
|
|
||||||
letsencrypt:
|
|
||||||
image: jrcs/letsencrypt-nginx-proxy-companion
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- gunicorn-socket:/var/gunicorn
|
|
||||||
- conf:/etc/nginx/conf.d
|
|
||||||
- vhost:/etc/nginx/vhost.d
|
|
||||||
- html:/usr/share/nginx/html
|
|
||||||
- certs:/etc/nginx/certs:rw
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
||||||
networks:
|
|
||||||
- nginx_network
|
|
||||||
depends_on:
|
|
||||||
- nginx
|
|
||||||
db:
|
db:
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- database_network
|
- database_network
|
||||||
depends_on:
|
|
||||||
- letsencrypt
|
|
||||||
django:
|
django:
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- gunicorn-socket:/var/gunicorn
|
|
||||||
- ./config/gunicorn.conf.py:/config/gunicorn.conf.py
|
- ./config/gunicorn.conf.py:/config/gunicorn.conf.py
|
||||||
|
- gunicorn-socket:/var/gunicorn
|
||||||
|
- staticfiles:/code/backend/static
|
||||||
networks:
|
networks:
|
||||||
- database_network
|
- database_network
|
||||||
- nginx_network
|
- server_network
|
||||||
environment:
|
environment:
|
||||||
- ENVIRONMENT=production
|
- ENVIRONMENT=production
|
||||||
- DJANGO_SETTINGS_MODULE=backend.settings.production
|
- DJANGO_SETTINGS_MODULE=backend.settings.production
|
||||||
- VIRTUAL_HOST
|
caddy:
|
||||||
- LETSENCRYPT_HOST
|
restart: always
|
||||||
- LETSENCRYPT_EMAIL
|
image: abiosoft/caddy:0.11.4-no-stats
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
volumes:
|
||||||
|
- ./config/Caddyfile:/etc/Caddyfile
|
||||||
|
- staticfiles:/srv/static
|
||||||
|
- caddycerts:/etc/caddycerts
|
||||||
|
networks:
|
||||||
|
- server_network
|
||||||
|
depends_on:
|
||||||
|
- django
|
||||||
|
environment:
|
||||||
|
- ACME_AGREE
|
||||||
|
- CADDYPATH=/etc/caddycerts
|
||||||
gephi:
|
gephi:
|
||||||
networks:
|
networks:
|
||||||
- database_network
|
- database_network
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
networks:
|
networks:
|
||||||
database_network:
|
database_network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
nginx_network:
|
server_network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
volumes:
|
volumes:
|
||||||
gunicorn-socket:
|
gunicorn-socket:
|
||||||
conf:
|
caddycerts:
|
||||||
vhost:
|
staticfiles:
|
||||||
html:
|
|
||||||
certs:
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ services:
|
||||||
db:
|
db:
|
||||||
image: postgres
|
image: postgres
|
||||||
environment:
|
environment:
|
||||||
# Set these in .env
|
|
||||||
- POSTGRES_USER
|
- POSTGRES_USER
|
||||||
- POSTGRES_PASSWORD
|
- POSTGRES_PASSWORD
|
||||||
- POSTGRES_DB
|
- POSTGRES_DB
|
||||||
|
@ -13,7 +12,6 @@ services:
|
||||||
- pgdata:/var/lib/postgresql/data
|
- pgdata:/var/lib/postgresql/data
|
||||||
django:
|
django:
|
||||||
environment:
|
environment:
|
||||||
# Set these in .env
|
|
||||||
- SECRET_KEY
|
- SECRET_KEY
|
||||||
- POSTGRES_USER
|
- POSTGRES_USER
|
||||||
- POSTGRES_PASSWORD
|
- POSTGRES_PASSWORD
|
||||||
|
|
|
@ -3,6 +3,4 @@ POSTGRES_USER=postgres
|
||||||
POSTGRES_PASSWORD=postgres
|
POSTGRES_PASSWORD=postgres
|
||||||
POSTGRES_DB=fediverse
|
POSTGRES_DB=fediverse
|
||||||
DJANGO_SETTINGS_MODULE=backend.settings.development
|
DJANGO_SETTINGS_MODULE=backend.settings.development
|
||||||
VIRTUAL_HOST=api.fediverse.space
|
ACME_AGREE=true
|
||||||
LETSENCRYPT_HOST=api.fediverse.space
|
|
||||||
LETSENCRYPT_EMAIL=my@email.com
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import fetch from "cross-fetch";
|
import fetch from "cross-fetch";
|
||||||
|
|
||||||
const API_ROOT =
|
const API_ROOT =
|
||||||
process.env.NODE_ENV === "development" ? "http://localhost:8000/api/v1/" : "https://api.fediverse.space/api/v1/";
|
process.env.NODE_ENV === "development" ? "http://localhost:8000/api/v1/" : "https://backend.fediverse.space/api/v1/";
|
||||||
|
|
||||||
export const getFromApi = (path: string): Promise<any> => {
|
export const getFromApi = (path: string): Promise<any> => {
|
||||||
const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/";
|
const domain = API_ROOT.endsWith("/") ? API_ROOT : API_ROOT + "/";
|
||||||
|
|
Loading…
Reference in a new issue