Skip to content

feat: create Dockerfile for local host testing #2

feat: create Dockerfile for local host testing

feat: create Dockerfile for local host testing #2

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: |
# stop if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build Docker image
run: docker compose build
- name: Run service stability test
env:
TEST_TELEGRAM_TOKEN: ${{ secrets.TEST_TELEGRAM_TOKEN }}
FEEDBACK_CHANNEL_ID: ${{ secrets.FEEDBACK_CHANNEL_ID }}
MONGO_URL: ${{ secrets.MONGO_URL }}
GITHUB_URL: ${{ secrets.GITHUB_URL }}
run: |
# Start service
docker compose up -d
# Monitor for 1 minute
START_TIME=$(date +%s)
END_TIME=$((START_TIME + 60))
while [ $(date +%s) -lt $END_TIME ]; do
# Check if container is still running
if ! docker ps | grep -q terrier-alert; then
echo "Service crashed!"
docker compose logs
exit 1
fi
sleep 5
done
# If we get here, service ran for 1 minute successfully
echo "Service ran stable for 1 minute"
docker compose down