Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JHDBot Dockerfile Rebuild #66

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
31 changes: 22 additions & 9 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Check Apps For Errors And Build Docker Images

on:
pull_request:
branches: [ master ]
push:
branches: [ master ]

Expand Down Expand Up @@ -61,20 +63,31 @@ jobs:
needs: jhdbot-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
-
name: Checkout repo
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: JHDBot
context: ./JHDBot
file: ./JHDBot/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: jhdiscord/jhd-bot-docker:latest
tags: jhdiscord/jhd-bot-docker:${{ github.sha }}


verify-app-docker:
name: Build and push Verify App
Expand All @@ -94,7 +107,7 @@ jobs:
context: verify-web
file: ./verify-web/Dockerfile
push: true
tags: jhdiscord/verify-app-docker:latest
tags: jhdiscord/verify-app-docker:${{ github.sha }}

nginx-docker:
name: Build and push nginx
Expand All @@ -113,4 +126,4 @@ jobs:
with:
context: .
push: true
tags: jhdiscord/nginx-docker:latest
tags: jhdiscord/nginx-docker:${{ github.sha }}
1 change: 0 additions & 1 deletion JHDBot/.dockerignore

This file was deleted.

48 changes: 40 additions & 8 deletions JHDBot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM python:3.7.8-alpine
# Builder image
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7.8-alpine as builder

RUN mkdir -p /usr/src/app
RUN mkdir /usr/src/app/gifs
WORKDIR /usr/src/app
ARG TARGETPLATFORM

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

# Install packages
RUN apk add --update --no-cache \
gcc \
python3-dev \
Expand All @@ -15,10 +20,37 @@ RUN apk add --update --no-cache \
libxslt-dev \
libxslt

COPY bot.py .
COPY cogs .
COPY requirements.txt .
COPY requirements.txt .

# Build python
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /wheels -r requirements.txt

# Final image; no build dependencies so image is smaller
FROM --platform=${TARGETPLATFORM:-linux/amd64} python:3.7.8-alpine

# Add non root user
RUN addgroup -S app && adduser app -S -G app

WORKDIR /home/app/

# Copy project files
COPY --from=builder /wheels ./wheels
COPY --from=builder /app/requirements.txt .

COPY bot.py .
COPY cogs .
COPY gifs .

# Setup permissions and user path
RUN chown -R app /home/app && \
mkdir -p /home/app/python && chown -R app /home/app
USER app
ENV PATH=$PATH:/home/app/.local/bin:/home/app/python/bin/
ENV PYTHONPATH=$PYTHONPATH:/home/app/python

# Install previously built python wheels
RUN pip install --no-cache /home/app/wheels/* --target=/home/app/python

RUN pip install -r requirements.txt
HEALTHCHECK CMD discordhealthcheck || exit 1

CMD ["python", "bot.py"]
13 changes: 0 additions & 13 deletions JHDBot/Pipfile

This file was deleted.

208 changes: 0 additions & 208 deletions JHDBot/Pipfile.lock

This file was deleted.

2 changes: 2 additions & 0 deletions JHDBot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from discord import Intents
from discord.ext import commands
from dotenv import load_dotenv
import discordhealthcheck

load_dotenv()

Expand All @@ -21,6 +22,7 @@
) # bot command prefix
bot.remove_command("help")
# Loading Cogs
discordhealthcheck.start(bot)

extensions = ["moderation", "veteran", "general", "verification"]

Expand Down
30 changes: 28 additions & 2 deletions JHDBot/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
aiohttp==3.7.4.post0
appdirs==1.4.4
async-timeout==3.0.1
attrs==22.1.0
beautifulsoup4==4.11.1
bs4==0.0.1
certifi==2022.6.15
chardet==3.0.4
cssselect==1.1.0
discord.py==1.7.3
python-dotenv
urllib3==1.25.8
discordhealthcheck==0.0.8
fake-useragent==0.1.11
idna==2.10
importlib-metadata==4.12.0
lxml==4.9.1
multidict==6.0.2
parse==1.19.0
pyee==8.2.2
pyppeteer==1.0.2
pyquery==1.4.3
python-dotenv==0.21.0
requests==2.23.0
requests-html==0.10.0
soupsieve==2.3.2.post1
tqdm==4.64.1
typing-extensions==4.3.0
urllib3==1.25.8
w3lib==2.0.1
websockets==10.3
yarl==1.8.1
zipp==3.8.1
Loading