diff --git a/README.md b/README.md index d5a2a58..491bb33 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Ubuntu -Install Ubuntu server +### Install Ubuntu server * Download the 16.04 Server ISO from https://www.ubuntu.com/download * Disconnect your media drives @@ -25,140 +25,184 @@ Install Ubuntu server * Standard system utilities * OpenSSH server -Log into server +### Log into server * Log into the server to get the IP address. Type `ip a` for your servers ip address. Or check your router to see what ip it was given. * You can now loginto your server via SSH using Bash in windows 10 `ssh username@ip` - ```bash - ssh username@192.168.1.40 - example - ``` +```bash +ssh username@192.168.1.40 - example +``` * Update and install upgrades - ```bash - sudo apt update - sudo apt upgrade - ``` +```bash +sudo apt update +sudo apt upgrade +``` ## Setting up BTRFS -* Shutdown the server and power off using the command `sudo poweroff`. +* Shutdown the server and power off using the command `sudo poweroff` * Install the data drives into the server and power up. * Check if the disks are now visible ot the system by issuing `lsblk`. You shoudl see the disks. ex. - * sdb - * sdc - * sdc - * and so forth + * sdb + * sdc + * sdc + * and so forth * Create the mount point for the file system to live. In this tutorial I will use BigPurple as the name of the directory. Use what you wish to call it. - ```bash - sudo mkdir /mnt/BigPurple - ``` +```bash +sudo mkdir /mnt/BigPurple +``` + * Create the first BTRFS file structure ```bash sudo mkfs.btrfs -L “BigPurple” -f /dev/sdb ``` + * Mount the drive. We will use the first available drive for the mount point. In my example it is sdb. ```bash sudo mount /dev/sdb /mnt/BigPurple ``` + * Create the subvolume. * Change into the directory of the mount point. + ```bash cd /mnt/BigPurple ``` + * Create the subvolume. + ```bash sudo btrfs subvolume create BigPurple ``` + * Get out of the BigPurple directory by typing ``cd`` and hitting enter. + * Unmount the drive. + ```bash sudo umount /mnt/BigPurple ``` + * Remount the subvolum with these options. + ```bash sudo mount -o compress=zlib,subvol=BigPurple,autodefrag /dev/sdb /mnt/BigPurple ``` + * Adding other drives to the BTRFS filesystem. + * Add all the remaing drives one by one. Do this for each drive untill they are all a part of the BigPurple filesystem + ```bash sudo btrfs device add -f /dev/sdc /mnt/BigPurple ``` + * Check to see if all devices are listed. + ```bash sudo btrfs filesystem show /mnt/BigPurple ``` + * Convert the BTRFS to a Raid1 - Raid 1 will split your total storage by half but give you better redundancy. + ```bash sudo btrfs filesystem balance start -dconvert=raid1 -mconvert=raid1 /mnt/BigPurple ``` + * Setting up the FSTAB * We need to make sure the server mounts the drives on reboot. * Get the subvolume ID + ```bash sudo btrfs subvolume list /mnt/BigPurple ``` + * Edit the /etc/fstab file + ```bash sudo nano /etc/fstab ``` + * Add this line to the bottom of the fstab. Use the same mnt point we used before and make sure to use the correct subvol name. (That is all one line) + ``` /dev/sdb /mnt/BigPurple btrfs defaults,compress=zlib,subvolid=257,autodefrag 0 0 ``` + * Save by hitting ctrl-x, say Y and enter * Reboot + ```bash sudo reboot ``` + * Log back in and check that the volumes mounted correctly + ```bash df -h sudo btrfs filesystem show /mnt/BigPurple ``` + ## Installing Docker -* Follow the instructions here: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04 +* Follow the instructions here: + + * https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04 + * Install docker-compose -```bash -sudo apt install docker-compose -``` + + ```bash + sudo apt install docker-compose + ``` * Set the environment up -```bash -sudo pico /etc/environment -``` + ```bash + sudo pico /etc/environment + ``` + * Paste these lines into the bottom of the file. -``` -PUID=1000 -PGID=1000 -``` + + ``` + PUID=1000 + PGID=1000 + ``` + * Set user and permissions for the server -```bash -sudo chmod 777 -R /mnt/BigPurple -``` + + ```bash + sudo chmod 777 -R /mnt/BigPurple + ``` ## Installing the Server using Docker Compose -* Check out this repository to your /opt directory. -```bash -cd /opt -git clone https://github.com/NoobTaco/MediaServer2018.git . -``` +* Check out this repository to your /opt directory. Be sure to have the period/full stop, at the end of the git clone line. + + ```bash + cd /opt + git clone https://github.com/NoobTaco/MediaServer2018.git . + ``` + * Make edits to the docker-compose.yml file. - * Change directory names to point to your directory structure. Again in this example I am using BigPurple - -## Adding SSL Proxy settings. + * Change directory names to point to your directory structure. Again in this example I am using BigPurple. + +## Adding SSL Proxy settings + +_Optional_ -Optional +If you wish to use ssl proxy domain names for your server then uncoment the following containers: +* ngnix +* nginx-gen +* letsencrypt-nginx-proxy-companion -If you wish to use ssl and domain names for your server then add the following block to each container in the docker-compose.yml file that you wish to expose. +Then add or uncomment the following blocks of environment settings for each container you wish to have outward exposure. ``` environment: @@ -175,9 +219,6 @@ After you bring the server up, letsencrypt will check to see if it has a valid S Your MUST have port 443 and 80 open on your router as well as have your domain register set to send the subdomains to your server. -Uncoment these blocks in the docker-compose.yml to use. - - ## Starting the Server Navigate to your /opt directory and issue the following command to start downloading and starting all the servers. @@ -185,9 +226,7 @@ Navigate to your /opt directory and issue the following command to start downloa ```bash sudo docker-compose -f /opt/docker-compose.yml up -d ``` -If you are using the SSL proxy please be patient as it can take a while to generate the certs. - -You can check the status of your servers by issuing `docker ps` to list the running containers. - +If you are using the SSL proxy please be patient as it can take a while to generate the certs. +You can check the status of your servers by issuing `docker ps` to list the running containers. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4d60669..eda1ed9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,51 +1,13 @@ +####### +## +## Media Server 2018 Guide by NoobTaco +## version: 0.0.3 +## +####### + version: '2' services: - ### - ### Nginx - Web server and Proxy - ### - nginx: - restart: always - image: nginx - container_name: nginx - ports: - - "80:80" - - "443:443" - volumes: - - "/etc/nginx/conf.d" - - "/etc/nginx/vhost.d" - - "/usr/share/nginx/html" - - "/opt/appdata/proxy/certs:/etc/nginx/certs:ro" - - ### - ### Nginx - Creates the web server config files for the containers calling it. - ### - nginx-gen: - restart: always - image: jwilder/docker-gen - container_name: nginx-gen - volumes: - - "/var/run/docker.sock:/tmp/docker.sock:ro" - - "/opt/appdata/proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" - 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 - - ### - ### Letsencrypt Nginx Proxy Companion - This is the majic sauce! - ### - letsencrypt-nginx-proxy-companion: - restart: always - 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" - - "/opt/appdata/proxy/certs:/etc/nginx/certs:rw" - environment: - - NGINX_DOCKER_GEN_CONTAINER=nginx-gen - ghost: image: ghost:1-alpine container_name: ghost @@ -54,7 +16,10 @@ services: - 8085:2368 volumes: - /opt/appdata/ghost:/var/lib/ghost/content -# environment: + environment: + - PUID=${PUID} + - PGID=${PGID} + - TZ=America/Los_Angeles # - VIRTUAL_HOST=blog.SOMEPLACE.COM # - VIRTUAL_NETWORK=nginx-proxy # - VIRTUAL_PORT=2368 @@ -142,10 +107,10 @@ services: - PUID=${PUID} - PGID=${PGID} - TZ=America/Los_Angeles -# - VIRTUAL_HOST=sonarr.SOMEPLACE.COM +# - VIRTUAL_HOST=mylar.SOMEPLACE.COM # - VIRTUAL_NETWORK=nginx-proxy # - VIRTUAL_PORT=8989 -# - LETSENCRYPT_HOST=sonarr.SOMEPLACE.COM +# - LETSENCRYPT_HOST=mylar.SOMEPLACE.COM # - LETSENCRYPT_EMAIL=something@someplace.com plex: @@ -158,9 +123,7 @@ services: - /mnt/BigPurple/transcode:/data/transcode network_mode: host restart: always - ### - ### Plex HW transcoding - Install NVIDIA drivers https://www.reddit.com/r/PleX/comments/749hnc/hardware_transcoding_with_plex_docker/ - ### +### Plex HW transcoding - Install NVIDIA drivers https://www.reddit.com/r/PleX/comments/749hnc/hardware_transcoding_with_plex_docker/ # devices: # - /dev/dri:/dev/dri environment: @@ -214,6 +177,24 @@ services: # - LETSENCRYPT_HOST=add.SOMEPLACE.COM # - LETSENCRYPT_EMAIL=something@someplace.com +muximux: + image: linuxserver/muximux + container_name: muximux + volumes: + - /opt/appdata/muximux:/config + ports: + - 7777:80 + restart: always + environment: + - PUID=${PUID} + - PGID=${PGID} + - TZ=America/Los_Angeles + # - VIRTUAL_HOST=media.SOMEPLACE.COM + # - VIRTUAL_NETWORK=nginx-proxy + # - VIRTUAL_PORT=80 + # - LETSENCRYPT_HOST=media.SOMEPLACE.COM + # - LETSENCRYPT_EMAIL=something@someplace.com + influxdb: image: tutum/influxdb container_name: influxdb @@ -221,6 +202,7 @@ services: environment: - PUID=${PUID} - PGID=${PGID} + - TZ=America/Los_Angeles ports: - 8083:8083 - 8086:8086 @@ -240,31 +222,16 @@ services: volumes: - /opt/appdata/grafana:/var/lib/grafana restart: always - # environment: + environment: + - PUID=${PUID} + - PGID=${PGID} + - TZ=America/Los_Angeles # - VIRTUAL_HOST=grafana.SOMEPLACE.COM # - VIRTUAL_NETWORK=nginx-proxy # - VIRTUAL_PORT=3000 # - LETSENCRYPT_HOST=grafana.SOMEPLACE.COM # - LETSENCRYPT_EMAIL=something@someplace.com - muximux: - image: linuxserver/muximux - container_name: muximux - volumes: - - /opt/appdata/muximux:/config - ports: - - 7777:80 - restart: always - environment: - - PUID=${PUID} - - PGID=${PGID} - - TZ=America/Los_Angeles - # - VIRTUAL_HOST=media.SOMEPLACE.COM - # - VIRTUAL_NETWORK=nginx-proxy - # - VIRTUAL_PORT=80 - # - LETSENCRYPT_HOST=media.SOMEPLACE.COM - # - LETSENCRYPT_EMAIL=something@someplace.com - portainer: image: portainer/portainer container_name: portainer @@ -274,4 +241,56 @@ services: - /opt/appdata/portainer:/data - /var/run/docker.sock:/var/run/docker.sock restart: - always \ No newline at end of file + always + environment: + - PUID=${PUID} + - PGID=${PGID} + - TZ=America/Los_Angeles + # - VIRTUAL_HOST=portainer.SOMEPLACE.COM + # - VIRTUAL_NETWORK=nginx-proxy + # - VIRTUAL_PORT=80 + # - LETSENCRYPT_HOST=portainer.SOMEPLACE.COM + # - LETSENCRYPT_EMAIL=something@someplace.com + + +######################## +### +### SSL Proxy containers. Uncoment these containers to use +### +######################## + + # nginx: + # restart: always + # image: nginx + # container_name: nginx + # ports: + # - "80:80" + # - "443:443" + # volumes: + # - "/etc/nginx/conf.d" + # - "/etc/nginx/vhost.d" + # - "/usr/share/nginx/html" + # - "/opt/appdata/proxy/certs:/etc/nginx/certs:ro" + + # nginx-gen: + # restart: always + # image: jwilder/docker-gen + # container_name: nginx-gen + # volumes: + # - "/var/run/docker.sock:/tmp/docker.sock:ro" + # - "/opt/appdata/proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" + # 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 + + # letsencrypt-nginx-proxy-companion: + # restart: always + # 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" + # - "/opt/appdata/proxy/certs:/etc/nginx/certs:rw" + # environment: + # - NGINX_DOCKER_GEN_CONTAINER=nginx-gen \ No newline at end of file