Remove old docker stuffs.

master
Nick Sergeant 2016-11-02 19:11:20 -04:00
parent 860f1afca5
commit e3a3ee5ecc
5 changed files with 0 additions and 278 deletions

View File

@ -1,61 +0,0 @@
#!/bin/bash
ACTION=$1
function stop_stack() {
docker stop snipt-proxy > /dev/null
docker stop snipt-app > /dev/null
docker stop snipt-es > /dev/null
docker stop snipt-pg > /dev/null
}
function start_stack() {
docker start snipt-pg > /dev/null
docker start snipt-es > /dev/null
docker start snipt-app > /dev/null
docker start snipt-proxy > /dev/null
}
if [ "$ACTION" = "syncdb" ]; then
docker run -it --rm -e DB_USER=postgres -e DB_NAME=postgres --net container:snipt-net snipt/snipt python manage.py syncdb --noinput
fi
if [ "$ACTION" = "migrate" ]; then
docker run -it --rm -e DB_USER=postgres -e DB_NAME=postgres --net container:snipt-net snipt/snipt python manage.py migrate --noinput
fi
if [ "$ACTION" = "collectstatic" ]; then
docker run -it --rm -v $(pwd)/static:/app/snipt/static --net container:snipt-net snipt/snipt python manage.py collectstatic --noinput
fi
if [ "$ACTION" = "deploy" ]; then
echo "pulling latest image"
docker pull snipt/snipt
echo "stopping app"
docker kill snipt-app
docker rm snipt-app
echo "deploying new container"
docker run -it --name snipt-app -d -e DB_PORT_5432_TCP_ADDR=127.0.0.1 -e DB_PORT_5432_TCP_PORT=5432 -e DB_USER=postgres -e DB_NAME=snipt -e DEBUG=false -v /etc/settings_local.py:/app/snipt/settings_local.py --net container:snipt-net snipt/snipt
sleep 5
docker restart snipt-proxy
echo "done"
fi
if [ "$ACTION" = "restart" ]; then
echo "restarting app"
docker restart snipt-app
fi
if [ "$ACTION" = "restart-stack" ]; then
echo "restarting stack"
stop_stack
start_stack
fi
if [ "$ACTION" = "backupdb" ]; then
echo "backing up db"
docker run --rm --net container:snipt-net --entrypoint pg_dump postgres:9.1 -h 127.0.0.1 -U postgres snipt
fi
if [ "$ACTION" = "psql" ]; then
docker run it --rm --net container:snipt-net --entrypoint psql postgres:9.1 -h 127.0.0.1 -U postgres snipt
fi

View File

@ -1,35 +0,0 @@
#!/bin/bash
COMPONENTS=$*
if [ -z "$COMPONENTS" ]; then
echo "Usage: $0 [components]"
exit 1
fi
for CMP in $COMPONENTS; do
if [ "$CMP" = "postgres" -o "$CMP" = "all" ]; then
echo "destroying postgres"
docker kill snipt-pg > /dev/null
docker rm snipt-pg > /dev/null
fi
if [ "$CMP" = "elasticsearch" -o "$CMP" = "all" ]; then
echo "destroying elasticsearch"
docker kill snipt-es > /dev/null
docker rm snipt-es > /dev/null
fi
if [ "$CMP" = "app" -o "$CMP" = "all" ]; then
echo "destroying app"
docker kill snipt-app > /dev/null
docker rm snipt-app > /dev/null
fi
if [ "$CMP" = "proxy" -o "$CMP" = "all" ]; then
echo "destroying proxy"
docker kill snipt-proxy > /dev/null
docker rm snipt-proxy > /dev/null
fi
if [ "$CMP" = "all" ]; then
echo "destroying shared net"
docker kill snipt-net > /dev/null
docker rm snipt-net > /dev/null
fi
done

View File

@ -1,119 +0,0 @@
user root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log off;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
upstream backend_snipt {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name *.snipt.net;
if ($host ~* "^([^.]+(\.[^.]+)*)\.snipt.net$"){
set $subd $1;
rewrite ^(.*)$ https://$subd.snipt.net$1 permanent;
break;
}
}
server {
listen 80;
server_name snipt.net www.snipt.net beta.snipt.net;
rewrite ^(.*) https://snipt.net$1 permanent;
}
server {
listen 443;
server_name www.snipt.net;
access_log off;
error_log /logs/nginx.log;
ssl on;
ssl_certificate /etc/certs/2013-dnsimple/snipt.net.crt;
ssl_certificate_key /etc/certs/2013-dnsimple/snipt.net.key;
rewrite ^(.*) https://snipt.net$1 permanent;
}
server {
listen 443;
server_name snipt.net *.snipt.net;
access_log off;
error_log /logs/nginx.log;
ssl on;
ssl_certificate /etc/certs/2013-dnsimple/snipt.net.crt;
ssl_certificate_key /etc/certs/2013-dnsimple/snipt.net.key;
location ~* /favicon.ico {
root /app/snipt/static/img/;
expires max;
}
location / {
rewrite_by_lua '
if string.find(ngx.var.host, "_") then
local newHost, n = ngx.re.gsub(ngx.var.host, "_", "-")
ngx.redirect(ngx.var.scheme .. "://" .. newHost .. ngx.var.uri)
end
';
proxy_pass http://backend_snipt;
proxy_set_header Host $host;
}
location /static/ {
alias /app/snipt/static/;
expires max;
}
location /public/feed/ {
rewrite ^/public/feed/$ https://snipt.net/public/?rss permanent;
}
}
server {
listen 80 default_server;
access_log off;
error_log /logs/nginx.log;
location ~* /favicon.ico {
root /app/snipt/static/img/;
expires max;
}
location / {
proxy_pass http://backend_snipt;
proxy_set_header Host $host;
}
location /static/ {
alias /app/snipt/static/;
expires max;
}
}
}

View File

@ -1,17 +0,0 @@
#!/bin/bash
APP_ROOT=/app
APP_DIR=$APP_ROOT/snipt
COOKIE_DOMAIN=${SESSION_COOKIE_DOMAIN:-.snipt.net}
SECRET_KEY=${SECRET_KEY:-changeme}
if [ ! -e "$APP_DIR/settings_local.py" ]; then
cp $APP_DIR/settings_local-template.py $APP_DIR/settings_local.py
sed -i "s/^SESSION_COOKIE_DOMAIN.*/SESSION_COOKIE_DOMAIN = '$COOKIE_DOMAIN'/g" $APP_DIR/settings_local.py
sed -i "s/^SECRET_KEY.*/SECRET_KEY = '$SECRET_KEY'/g" $APP_DIR/settings_local.py
fi
pushd $APP_DIR
python manage.py syncdb --noinput
python manage.py migrate --noinput
popd
pushd $APP_DIR
python manage.py run_gunicorn -c $APP_DIR/gunicorn.conf.server.py

View File

@ -1,46 +0,0 @@
#!/bin/bash
COMPONENTS=$*
if [ -z "$COMPONENTS" ]; then
echo "Usage: $0 [components]"
exit 1
fi
for CMP in $COMPONENTS; do
if [ "$CMP" = "net" -o "$CMP" = "all" ]; then
# start net container
docker run -it -p 80:80 -p 443:443 --name snipt-net -d debian:jessie bash > /dev/null
sleep 1
fi
if [ "$CMP" = "postgres" -o "$CMP" = "all" ]; then
echo "starting postgres"
docker run -it -d --name snipt-pg --net container:snipt-net postgres:9.1 > /dev/null
# wait for PG to start
sleep 5
# create db
docker run -it --rm --net container:snipt-net --entrypoint createdb postgres:9.1 -h 127.0.0.1 -U postgres -E UTF8 -O postgres snipt
fi
if [ "$CMP" = "elasticsearch" -o "$CMP" = "all" ]; then
echo "starting elasticsearch"
docker run -it -d --name snipt-es --net container:snipt-net arcus/elasticsearch > /dev/null
sleep 1
fi
if [ "$CMP" = "app" -o "$CMP" = "all" ]; then
echo "starting app"
# migrate
docker run -it --rm -e DB_USER=postgres -e DB_NAME=snipt --net container:snipt-net snipt/snipt python manage.py syncdb --noinput
docker run -it --rm -e DB_USER=postgres -e DB_NAME=snipt --net container:snipt-net snipt/snipt python manage.py migrate --noinput
# collect static
docker run -it --rm -v $(pwd)/static:/app/snipt/static --net container:snipt-net snipt/snipt python manage.py collectstatic --noinput
# run app
docker run -it --name snipt-app -d -e DB_PORT_5432_TCP_ADDR=127.0.0.1 -e DB_PORT_5432_TCP_PORT=5432 -e DB_USER=postgres -e DB_NAME=snipt -e DEBUG=false -v /etc/settings_local.py:/app/snipt/settings_local.py --net container:snipt-net snipt/snipt > /dev/null
sleep 1
fi
if [ "$CMP" = "proxy" -o "$CMP" = "all" ]; then
echo "starting proxy"
docker run -d --name snipt-proxy -it -v /var/log/snipt:/logs -v $(pwd)/.docker/nginx.conf:/etc/nginx/nginx.conf -v $(pwd)/static:/app/snipt/static -v /etc/certs:/etc/certs --net container:snipt-net snipt/proxy nginx -g 'daemon off;' -c /etc/nginx/nginx.conf > /dev/null
fi
done