diff --git a/README.md b/README.md index ca42125..4041b67 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,15 @@ **FEH Gauntlet Bot** is a Twitter bot thats posts hourly updates when disadvantage multipliers are up for #FEHeroes Voting Gauntlets! [Click here to view its Twitter page!](https://twitter.com/FEHGauntletBot) See more at [https://atemosta.com/projects/feh-gauntlet-bot/](https://atemosta.com/projects/feh-gauntlet-bot/) + +## To Build and Upload the Docker Images +``` +chmod +x upload_latest_docker.sh +./upload_latest_docker.sh +``` + +## To Deploy the Docker Services +``` +chmod +x deploy_docker_services.sh +./deploy_docker_services.sh +``` \ No newline at end of file diff --git a/archive/docker_build.sh b/archive/docker_build.sh index 4e02c76..f9a845f 100644 --- a/archive/docker_build.sh +++ b/archive/docker_build.sh @@ -14,7 +14,7 @@ docker stop $(docker ps -a -q) docker rm $(docker ps -a -q) # Upload -docker login atemosta +docker login docker tag atemosta/feh-gauntlet-bot atemosta/feh-gauntlet-bot:1.11 docker tag atemosta/feh-gauntlet-bot atemosta/feh-gauntlet-bot:latest # docker push atemosta/feh-gauntlet-bot:1.11 diff --git a/initial_server_setup.sh b/archive/initial_do_server_setup.sh similarity index 100% rename from initial_server_setup.sh rename to archive/initial_do_server_setup.sh diff --git a/convoy/Dockerfile b/convoy/Dockerfile index 88a9599..8b380f6 100644 --- a/convoy/Dockerfile +++ b/convoy/Dockerfile @@ -1,5 +1,5 @@ # Select Docker image -FROM python:3.8-slim +FROM python:3.8-slim-buster # Create app directory WORKDIR /app @@ -16,6 +16,6 @@ RUN pip install -r requirements.txt COPY api.py /app COPY config.py /app COPY gauntlet_template.py /app -COPY secrets.py /app +# COPY secrets.py /app diff --git a/convoy/api.py b/convoy/api.py index 6b705e1..4e14351 100644 --- a/convoy/api.py +++ b/convoy/api.py @@ -6,7 +6,7 @@ # --- Local Config Imports --- # from config import * # current VG particpants and round dates from gauntlet_template import * -from secrets import * +from assets.secrets import * app = FastAPI() diff --git a/deploy_docker_services.sh b/deploy_docker_services.sh new file mode 100755 index 0000000..9b736b3 --- /dev/null +++ b/deploy_docker_services.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Copy Secret Credentials to Mounted Volume +echo "Attempting to copy secret credentials..." +cp secrets.py assets/ +echo "Successfully copied secret credentials!" + +# Run Latest Docker Images +echo "Attempting to update Docker images..." +docker-compose down +docker-compose up -d +echo "Successfully updated Docker images!" \ No newline at end of file diff --git a/discord/genny/Dockerfile b/discord/genny/Dockerfile index 3a59f3d..60edad2 100644 --- a/discord/genny/Dockerfile +++ b/discord/genny/Dockerfile @@ -1,5 +1,5 @@ # Select Docker image -FROM python:3.8-slim +FROM python:3.8-slim-buster # Create app directory WORKDIR /app diff --git a/discord/rebecca/Dockerfile b/discord/rebecca/Dockerfile index e1681e1..cffaaf0 100644 --- a/discord/rebecca/Dockerfile +++ b/discord/rebecca/Dockerfile @@ -1,5 +1,5 @@ # Select Docker image -FROM python:3.8-slim +FROM python:3.8-slim-buster # Create app directory WORKDIR /app diff --git a/docker-compose.yml b/docker-compose.yml index 9772e0a..4757e7e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.8" services: convoy: - build: convoy + image: atemosta/feh-gauntlet-bot:convoy-latest command: uvicorn api:app --host 0.0.0.0 --port 5057 --reload networks: - feh-compose-network @@ -10,7 +10,7 @@ services: volumes: - ./assets:/app/assets genny: - build: discord/genny + image: atemosta/feh-gauntlet-bot:genny-latest command: python genny.py depends_on: - convoy @@ -21,7 +21,7 @@ services: volumes: - ./assets:/app/assets rebecca: - build: discord/rebecca + image: atemosta/feh-gauntlet-bot:rebecca-latest command: python rebecca.py depends_on: - convoy diff --git a/upload_latest_docker.sh b/upload_latest_docker.sh new file mode 100755 index 0000000..ea990b3 --- /dev/null +++ b/upload_latest_docker.sh @@ -0,0 +1,49 @@ +# Set Docker Image Version +export DOCKER_VERSION=1.59 + +# Build, Deploy, and Tear Down Docker Containers +echo "Attempting to build Docker containers..." +docker build -t feh-gauntlet-bot_convoy ./convoy/ +docker build -t feh-gauntlet-bot_genny ./discord/genny/ +docker build -t feh-gauntlet-bot_rebecca ./discord/rebecca/ + +echo "----------Success!!!----------" + +# Log Into Docker +echo "Attempting to log into Docker..." +docker login +echo "----------Success!!!----------" + +# Upload Latest Convoy Image +echo "Attempting to upload latest Convoy images..." +docker tag feh-gauntlet-bot_convoy atemosta/feh-gauntlet-bot:convoy-${DOCKER_VERSION} +docker push atemosta/feh-gauntlet-bot:convoy-${DOCKER_VERSION} +docker tag feh-gauntlet-bot_convoy atemosta/feh-gauntlet-bot:convoy-latest +docker push atemosta/feh-gauntlet-bot:convoy-latest +echo "----------Success!!!----------" + +# Upload Latest Genny Image +echo "Attempting to upload latest Genny images..." +docker tag feh-gauntlet-bot_genny atemosta/feh-gauntlet-bot:genny-${DOCKER_VERSION} +docker push atemosta/feh-gauntlet-bot:genny-${DOCKER_VERSION} +docker tag feh-gauntlet-bot_genny atemosta/feh-gauntlet-bot:genny-latest +docker push atemosta/feh-gauntlet-bot:genny-latest +echo "----------Success!!!----------" + +# Upload Latest Rebecca Image +echo "Attempting to upload latest Rebecca images..." +docker tag feh-gauntlet-bot_rebecca atemosta/feh-gauntlet-bot:rebecca-${DOCKER_VERSION} +docker push atemosta/feh-gauntlet-bot:rebecca-${DOCKER_VERSION} +docker tag feh-gauntlet-bot_rebecca atemosta/feh-gauntlet-bot:rebecca-latest +docker push atemosta/feh-gauntlet-bot:rebecca-latest +echo "----------Success!!!----------" + + +# Clear Docker Containers and Images +echo "Clearing old docker images..." +docker stop $(docker ps -a -q) +docker rm $(docker ps -a -q) +export IMAGE_PATTERN=feh-gauntlet-bot +docker images -a | grep ${IMAGE_PATTERN} +docker images -a | grep ${IMAGE_PATTERN} | awk '{print $3}' | xargs docker rmi -f +echo "----------Success!!!----------"