Skip to content

Commit

Permalink
🐳 changes to allow the bot to work on Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jayktaylor committed Jan 14, 2018
1 parent 77e9a75 commit 0202dc6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .travis.yml
@@ -0,0 +1,25 @@
sudo: required
language: python

matrix:
include:
- env: TYPE=docker
sudo: required
- env: TYPE=build
os: linux
python: 3.5
dist: trusty
sudo: required

services:
- docker

install:
- if [ "$TYPE" = "build" ]; then ./.travis/install.sh; fi;

script:
- if [ "$TYPE" = "docker" ]; then docker build -t musicbot .; docker images -a; fi;
- if [ "$TYPE" = "build" ]; then python -m compileall ./musicbot; fi;

after_success:
- if [ "$TRAVIS_BRANCH" == "master" ]; then docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASS"; docker tag musicbot $DOCKER_USERNAME/musicbot ; docker push $DOCKER_USERNAME/musicbot; fi;
22 changes: 22 additions & 0 deletions .travis/install.sh
@@ -0,0 +1,22 @@
#!/bin/bash

if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
brew install git
brew install ffmpeg
brew install opus
brew install libffi
brew install libsodium
python3 -m pip install -U pip
python3 -m pip install -U -r requirements.txt
else
sudo apt-get install build-essential unzip -y
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes -y
sudo add-apt-repository ppa:mc3man/trusty-media -y
sudo add-apt-repository ppa:chris-lea/libsodium -y
sudo apt-get update -y
sudo apt-get install git python3.5-dev libav-tools libopus-dev libffi-dev libsodium-dev python3-pip -y
sudo apt-get upgrade -y
sudo python3 -m pip install -U pip
sudo python3 -m pip install -U -r requirements.txt
fi
2 changes: 2 additions & 0 deletions Dockerfile
Expand Up @@ -32,4 +32,6 @@ RUN apk update \
# Create volume for mapping the config
VOLUME /usr/src/musicbot/config

ENV APP_ENV=docker

ENTRYPOINT ["python3", "run.py"]
6 changes: 5 additions & 1 deletion run.py
Expand Up @@ -9,6 +9,7 @@
import subprocess

from shutil import disk_usage, rmtree
from base64 import b64decode

try:
import pathlib
Expand Down Expand Up @@ -276,10 +277,13 @@ def req_ensure_encoding():
def req_ensure_env():
log.info("Ensuring we're in the right environment")

if os.environ.get('APP_ENV') != 'docker' and not os.path.isdir(b64decode('LmdpdA==').decode('utf-8')):
log.critical(b64decode('Qm90IHdhc24ndCBpbnN0YWxsZWQgdXNpbmcgR2l0LiBSZWluc3RhbGwgdXNpbmcgaHR0cDovL2JpdC5seS9tdXNpY2JvdGRvY3Mu').decode('utf-8'))
bugger_off()

try:
assert os.path.isdir('config'), 'folder "config" not found'
assert os.path.isdir('musicbot'), 'folder "musicbot" not found'
assert os.path.isdir('.git'), 'bot was not installed using Git. If you downloaded a ZIP, you did it wrong. Open http://bit.ly/dmbguide on your browser for official install steps.'
assert os.path.isfile('musicbot/__init__.py'), 'musicbot folder is not a Python module'

assert importlib.util.find_spec('musicbot'), "musicbot module is not importable"
Expand Down

1 comment on commit 0202dc6

@glego
Copy link

@glego glego commented on 0202dc6 Mar 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaydenkieran , why did you implement this artificial restriction, and obfuscated the error message?

Please sign in to comment.