switching to alpine and using git.allucanget.biz docker registry
This commit is contained in:
41
.gitea/workflows/build-container.yaml
Normal file
41
.gitea/workflows/build-container.yaml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Build and Deploy Docker Container
|
||||||
|
run-name: ${{ gitea.actor }} runs docker deployment
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.allucanget.biz
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ secrets.REGISTRY_USERNAME }}/thc-webhook:latest
|
||||||
|
|
||||||
|
- name: Verify the Docker image is running
|
||||||
|
run: |
|
||||||
|
docker run -d --name test-thc-webhook -e DISCORD_WEBHOOK_URL=${{ secrets.DISCORD_WEBHOOK_URL }} -p 8080:8080 ${{ secrets.REGISTRY_USERNAME }}/thc-webhook:latest
|
||||||
|
sleep 10
|
||||||
|
if [ $(docker ps -q -f name=test-thc-webhook | wc -l) -eq 1 ]; then
|
||||||
|
echo "Container is running successfully."
|
||||||
|
docker logs test-thc-webhook
|
||||||
|
docker stop test-thc-webhook
|
||||||
|
docker rm test-thc-webhook
|
||||||
|
else
|
||||||
|
echo "Container failed to start."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
# Use official Python image
|
# Use official Python image
|
||||||
FROM python:3.11-slim
|
FROM python:3.12-alpine
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install system dependencies if needed (none for this app)
|
|
||||||
# RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Copy requirements and install Python dependencies
|
# Copy requirements and install Python dependencies
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
@@ -15,8 +12,8 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Create a non-root user
|
# Create a non-root user
|
||||||
RUN useradd --create-home --shell /bin/bash app
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
USER app
|
USER appuser
|
||||||
|
|
||||||
# Command to run the application
|
# Command to run the application
|
||||||
CMD ["python", "main.py"]
|
CMD ["python", "main.py"]
|
||||||
|
|||||||
7
main.py
7
main.py
@@ -16,10 +16,13 @@ load_dotenv()
|
|||||||
|
|
||||||
WEBHOOK_URL = os.getenv('DISCORD_WEBHOOK_URL')
|
WEBHOOK_URL = os.getenv('DISCORD_WEBHOOK_URL')
|
||||||
|
|
||||||
|
MSG_FOOTER = "THC - Toke Hash Coordinated"
|
||||||
|
|
||||||
MSG_TEST = "Discord 420 timer activated. This is a test notification."
|
MSG_TEST = "Discord 420 timer activated. This is a test notification."
|
||||||
MSG_REMINDER = "5 minute reminder!"
|
MSG_REMINDER = "5 minute reminder!"
|
||||||
MSG_HALFTIME = "Half-time!"
|
MSG_HALFTIME = "Half-time!"
|
||||||
MSG_NOTIFICATION = "420! Blaze it!"
|
MSG_NOTIFICATION = "420! Blaze it!"
|
||||||
|
|
||||||
COL_BLUE = 0x3498db
|
COL_BLUE = 0x3498db
|
||||||
COL_ORANGE = 0xe67e22
|
COL_ORANGE = 0xe67e22
|
||||||
COL_GREEN = 0x2ecc71
|
COL_GREEN = 0x2ecc71
|
||||||
@@ -54,9 +57,7 @@ def create_embed(message: str) -> dict:
|
|||||||
"description": msg["text"],
|
"description": msg["text"],
|
||||||
"color": msg["color"],
|
"color": msg["color"],
|
||||||
"timestamp": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
"timestamp": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||||
"footer": {
|
"footer": {"text": MSG_FOOTER}
|
||||||
"text": "THC - Toke Hash Coordinated"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user