-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1649d9a
commit ba9b4b9
Showing
6 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ setup | |
learning.service | ||
logs/ | ||
.env | ||
.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:3 | ||
RUN mkdir /api | ||
RUN mkdir -p /var/www/learning.nss.team | ||
WORKDIR /api | ||
ADD . /api/ | ||
RUN pip install -r requirements.txt | ||
ADD entrypoint.sh /entrypoint.sh | ||
RUN chmod a+x /entrypoint.sh | ||
COPY config/nginx/nginx.conf /etc/nginx/nginx.conf | ||
|
||
ENTRYPOINT [ "/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
upstream learningapicontainer { | ||
server apihost:8000; | ||
} | ||
|
||
server { | ||
if ($host = learningapi.nss.team) { | ||
return 301 https://$host$request_uri; | ||
} | ||
|
||
listen 80; | ||
server_name learningapi.nss.team; | ||
return 404; | ||
} | ||
|
||
server { | ||
listen 443 ssl; | ||
server_name learningapi.nss.team; | ||
|
||
location /static/ { | ||
autoindex off; | ||
root /var/www/learning.nss.team; | ||
} | ||
|
||
location / { | ||
proxy_set_header HOST $http_host; | ||
proxy_set_header X-NginX-Proxy true; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
|
||
include proxy_params; | ||
proxy_pass http://learningapicontainer; | ||
|
||
# Preflighted requests | ||
if ($request_method = OPTIONS ) { | ||
add_header "Access-Control-Allow-Origin" *; | ||
add_header "Access-Control-Allow-Methods" "GET, POST, PUT, DELETE, OPTIONS, HEAD"; | ||
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept"; | ||
return 200; | ||
} | ||
|
||
if ($request_method ~* "(GET|POST|PUT|DELETE)") { | ||
add_header "Access-Control-Allow-Origin" *; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
user www-data; | ||
worker_processes auto; | ||
pid /run/nginx.pid; | ||
|
||
events { | ||
worker_connections 768; | ||
} | ||
|
||
|
||
http { | ||
## | ||
# Basic Settings | ||
## | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
client_max_body_size 40m; | ||
# server_tokens off; | ||
|
||
# server_names_hash_bucket_size 64; | ||
# server_name_in_redirect off; | ||
|
||
default_type application/octet-stream; | ||
|
||
## Caching Settings | ||
# proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=512m; | ||
|
||
## | ||
# SSL Settings | ||
## | ||
|
||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE | ||
ssl_prefer_server_ciphers on; | ||
|
||
## | ||
# Logging Settings | ||
## | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
## | ||
# Gzip Settings | ||
## | ||
|
||
gzip on; | ||
gzip_disable "msie6"; | ||
|
||
# gzip_vary on; | ||
# gzip_proxied any; | ||
# gzip_comp_level 6; | ||
# gzip_buffers 16 8k; | ||
# gzip_http_version 1.1; | ||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | ||
|
||
## | ||
# Virtual Host Configs | ||
## | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
include /etc/nginx/sites-enabled/*; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
services: | ||
certbot: | ||
image: certbot/certbot | ||
volumes: | ||
- ./certs:/etc/letsencrypt | ||
command: certonly --webroot --webroot-path=/var/www/learning.nss.team --email [email protected] --agree-tos --non-interactive --domains -d learning.nss.team | ||
nginx: | ||
image: nginx:latest | ||
container_name: ng01 | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
volumes: | ||
- .:/api | ||
- ./config/nginx/conf.d:/etc/nginx/conf.d | ||
- ./certs:/etc/nginx/ssl | ||
depends_on: | ||
- certbot | ||
apihost: | ||
build: . | ||
container_name: learningapi | ||
command: gunicorn -w 3 -b 0.0.0.0:8000 LearningPlatform.wsgi | ||
volumes: | ||
- .:/api | ||
env_file: | ||
- .env | ||
depends_on: | ||
- nginx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
python manage.py makemigrations | ||
python manage.py migrate | ||
python manage.py collectstatic | ||
|
||
exec gunicorn -w 3 -b 0.0.0.0:8000 LearningPlatform.wsgi |