Added deployment using docker-compose. Fixed #70

This commit is contained in:
Vividh Mariy 2020-08-10 00:00:52 +05:30
parent 213c44a45a
commit 2cbc5ac441
3 changed files with 60 additions and 0 deletions

View File

@ -24,10 +24,14 @@
Installation of Shynet is easy! Follow the [Basic Installation](#basic-installation) guide below if you'd like to run Shynet over HTTP or if you are going to be running it over HTTPS through a reverse proxy. If you'd like to run Shynet over HTTPS without a reverse proxy, skip ahead to [Installation with SSL](#installation-with-ssl) instead. Installation of Shynet is easy! Follow the [Basic Installation](#basic-installation) guide below if you'd like to run Shynet over HTTP or if you are going to be running it over HTTPS through a reverse proxy. If you'd like to run Shynet over HTTPS without a reverse proxy, skip ahead to [Installation with SSL](#installation-with-ssl) instead.
If you're running this on a fresh server, or don't want to deal with too much configration right now, follow the [Quick Install](#quick-install) guide below.
> **These commands assume Ubuntu.** If you're installing Shynet on a different platform, the process will be different. > **These commands assume Ubuntu.** If you're installing Shynet on a different platform, the process will be different.
Before continuing, please be sure to have the latest version of Docker installed. Before continuing, please be sure to have the latest version of Docker installed.
### Basic Installation ### Basic Installation
1. Pull the latest version of Shynet using `docker pull milesmcc/shynet:latest`. If you don't have Docker installed, [install it](https://docs.docker.com/get-docker/). 1. Pull the latest version of Shynet using `docker pull milesmcc/shynet:latest`. If you don't have Docker installed, [install it](https://docs.docker.com/get-docker/).
@ -50,6 +54,29 @@ Before continuing, please be sure to have the latest version of Docker installed
10. Finally, click on "Manage" in the top right of the service's page to get the tracking script code. Inject this script on all pages you'd like the service to track. 10. Finally, click on "Manage" in the top right of the service's page to get the tracking script code. Inject this script on all pages you'd like the service to track.
### Quick Install
> Make sure you have `docker-compose` installed. If not, [install it](https://docs.docker.com/compose/install/)
1. Clone the repository.
2. Using [this file](/TEMPLATE.env) as a template, confiure the environment for your shynet instance, and place the modified config in a file called `.env` in the root of the repository. Do NOT change the port number at the end, you can set the public facing port in the next step.
3. Replace `example.com` with your hostname, on line 2 of the `nginx.conf` file located in the root of the repository. Also, in the `docker-compose.yml` file, set the port number by replacing `8080` in line 38 ( `- 8080:80` ) with whatever local port you want to bind it to. \
e.g. Set it to `- 80:80` so that your site will be available at http://hostname.
4. Launch the Shynet server for the first time by running `docker-compose up -d`. \
If you get an error like "permission denied" or "Couldn't connect to Docker daemon", either prefix the command with `sudo`, or add your user to the `docker` group.
5. Create an admin user by running `docker exec -it shynet_main ./manage.py registeradmin <your email>`. A temporary password will be printed to the console.
6. Set the hostname of your Shynet instance by running `docker exec -it shynet_main ./manage.py hostname <your public hostname>`, where <your public hostname> is the same you set in Step 3. This setting affects the URL that the tracking script sends its results to, so make sure it's correct. (Example hostnames: shynet.example.com or example.com:8000.)
7. Set the whitelabel of your Shynet instance by running `docker exec -it shynet_main ./manage.py whitelabel <whitelabel>`. While this setting doesn't affect any core operations of Shynet, it lets you rename Shynet to whatever you want. (Example whitelabels: "My Shynet Instance" or "Acme Analytics".)
Your site should now be accessible at `http://hostname:port`. After this, you can follow steps 9-10 of the [Basic Installation](#basic-installation) guide below to get up and running.
## Heroku ## Heroku
You may wish to deploy Shynet on Heroku. Note that Heroku's free offerings (namely the free Postgres addon) are unlikely to support running any Shynet instance that records more than a few hundred requests per day &mdash; the database will quickly fill up. In most cases, the more cost-effective option for running Shynet is renting a VPS from a full cloud service provider. However, if you're sure Heroku is the right option for you, or you just want to try Shynet out, you can use the Quick Deploy button then follow the steps below. You may wish to deploy Shynet on Heroku. Note that Heroku's free offerings (namely the free Postgres addon) are unlikely to support running any Shynet instance that records more than a few hundred requests per day &mdash; the database will quickly fill up. In most cases, the more cost-effective option for running Shynet is renting a VPS from a full cloud service provider. However, if you're sure Heroku is the right option for you, or you just want to try Shynet out, you can use the Quick Deploy button then follow the steps below.

View File

@ -1,6 +1,7 @@
version: '3' version: '3'
services: services:
shynet: shynet:
container_name: shynet_main
image: milesmcc/shynet:latest image: milesmcc/shynet:latest
restart: unless-stopped restart: unless-stopped
expose: expose:
@ -16,6 +17,7 @@ services:
depends_on: depends_on:
- db - db
db: db:
container_name: shynet_database
image: postgres image: postgres
restart: always restart: always
environment: environment:
@ -26,6 +28,18 @@ services:
- shynet_db:/var/lib/postgresql/data - shynet_db:/var/lib/postgresql/data
networks: networks:
- internal - internal
webserver:
container_name: shynet_webserver
image: nginx
restart: always
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- 8080:80
depends_on:
- shynet
networks:
- internal
volumes: volumes:
shynet_db: shynet_db:
networks: networks:

19
nginx.conf Normal file
View File

@ -0,0 +1,19 @@
server {
server_name example.com;
access_log /var/log/nginx/bin.access.log;
error_log /var/log/nginx/bin.error.log error;
location / {
proxy_pass http://shynet:8080;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Url-Scheme $scheme;
}
listen 80;
}