Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Streamline Docker Build Updates (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Kevin authored Jun 22, 2022
1 parent 70b1e86 commit e4cd5ec
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 9 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 1 addition & 1 deletion archive/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions convoy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Select Docker image
FROM python:3.8-slim
FROM python:3.8-slim-buster

# Create app directory
WORKDIR /app
Expand All @@ -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


2 changes: 1 addition & 1 deletion convoy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
12 changes: 12 additions & 0 deletions deploy_docker_services.sh
Original file line number Diff line number Diff line change
@@ -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!"
2 changes: 1 addition & 1 deletion discord/genny/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Select Docker image
FROM python:3.8-slim
FROM python:3.8-slim-buster

# Create app directory
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion discord/rebecca/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Select Docker image
FROM python:3.8-slim
FROM python:3.8-slim-buster

# Create app directory
WORKDIR /app
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
49 changes: 49 additions & 0 deletions upload_latest_docker.sh
Original file line number Diff line number Diff line change
@@ -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!!!----------"

0 comments on commit e4cd5ec

Please sign in to comment.