From 3fe233f26498979c6e19bd22ffd15a6f438cbc47 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Tue, 8 Aug 2017 15:55:01 -0700 Subject: [PATCH] Modifying the docker file to install docker on a separate step so we can cache that bit to speed up testing. also adding a script that will run some quick tests --- Dockerfile | 5 +++-- app/dragon-bot.py | 3 ++- test_container.sh | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100755 test_container.sh diff --git a/Dockerfile b/Dockerfile index acde5500..6625290c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM python:3.6.2-slim -RUN apt-get update && apt-get install -y curl &&\ - pip3 install requests discord.py docker pybooru && \ +RUN apt-get update && apt-get install curl -y &&\ curl -Lks get.docker.com | bash +RUN pip install requests discord.py docker pybooru termcolor + ADD app /app CMD python app/dragon-bot.py \ No newline at end of file diff --git a/app/dragon-bot.py b/app/dragon-bot.py index e725de65..3aa55e27 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -6,6 +6,7 @@ import help_methods import discord import docker from pybooru import Danbooru +from termcolor import colored # Client object client = discord.Client() @@ -260,7 +261,7 @@ async def on_message(message): # Check if there is a command line argument after script if len(sys.argv) > 1: - print("If you're seeing this, the python compiled") + print(colored("If you're seeing this, the python compiled", 'green')) sys.exit() token = "MzM5NDQ2NTgwMTU3MzQ5ODg4.DFkGYg.z-XD17nFP4rtBq-YsNbOJHuBWfQ" # get from the bot page. must be a bot, not a discord app diff --git a/test_container.sh b/test_container.sh new file mode 100755 index 00000000..a70749d5 --- /dev/null +++ b/test_container.sh @@ -0,0 +1,8 @@ +#!/bin/bash +printf "\nStarting tests\n" + +printf "Building docker container\n" +docker build -t tests . + +printf "Running docker container to test your python code\n" +docker run --rm tests python /app/dragon-bot.py test \ No newline at end of file