Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: CI/CD
on:
push:
branches:
- "main"
- main
- "feature/*"

jobs:
deploy:
Expand All @@ -22,24 +23,30 @@ jobs:
run: |
APP_NAME="thanksbot"
DATE=$(date +'%Y%m%d')
GITHUB_BRANCH=${{ github.ref_name }}
BUILD_NUM=${{ github.run_number }}
VERSION="${APP_NAME}-${DATE}-${GITHUB_BRANCH}-${BUILD_NUM}"
BRANCH="${{ github.ref_name }}"
BRANCH_SAFE=$(echo "$BRANCH" | tr '/ .' '---')
BUILD_NUM="${{ github.run_number }}"
VERSION="${APP_NAME}-${DATE}-${BRANCH_SAFE}-${BUILD_NUM}"
echo "appVersion=$VERSION" >> $GITHUB_ENV
echo "appVersion=$VERSION" >> $GITHUB_OUTPUT

- name: Log into Docker Registry
if: github.ref == 'refs/heads/main'
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin

- name: Build and tag Docker image
run: |
docker build -t $REGISTRY/${{ env.IMAGE_NAME }}:${{ env.appVersion }} -t $REGISTRY/${{ env.IMAGE_NAME }}:latest .
docker build \
-t "$REGISTRY/${{ env.IMAGE_NAME }}:${{ env.appVersion }}" \
-t "$REGISTRY/${{ env.IMAGE_NAME }}:latest" .

- name: Push Docker images
if: github.ref == 'refs/heads/main'
run: |
docker push $REGISTRY/${{ env.IMAGE_NAME }}:${{ env.appVersion }}
docker push $REGISTRY/${{ env.IMAGE_NAME }}:latest
docker push "$REGISTRY/${{ env.IMAGE_NAME }}:${{ env.appVersion }}"
docker push "$REGISTRY/${{ env.IMAGE_NAME }}:latest"

- name: Trigger Portainer webhook
if: github.ref == 'refs/heads/main'
run: |
curl -X POST ${{ secrets.PORTAINER_WEBHOOK_URL }}
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"
13 changes: 1 addition & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
# ---- Base (Debian 12 / bookworm) ----
FROM python:3.12-slim

# Keep Python logs unbuffered and avoid .pyc files
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
TZ=Europe/Paris

# Minimal runtime deps:
# - tzdata: timezone handling for logs
# - ca-certificates: TLS
# - libffi8: runtime for cffi
# - libsodium23: (usually not needed w/ PyNaCl wheels, but harmless/safe)
RUN apt-get update && apt-get install -y --no-install-recommends \
tzdata \
ca-certificates \
libffi8 \
libsodium23 \
&& rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN useradd -m -u 10001 thanksbotuser
WORKDIR /app

# Install Python deps first for better layer caching
COPY requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

# Copy the bot code
COPY . /app

# Drop privileges for runtime
USER thanksbotuser

# If your entrypoint is main.py at project root:
CMD ["python", "main.py"]
CMD ["python", "main.py"]