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
22 changes: 21 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish to PyPI
name: Publish to PyPI and Docker Hub

on:
push:
Expand Down Expand Up @@ -42,3 +42,23 @@ jobs:
run: |
poetry build
poetry publish

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/mysql-ch-replicator:latest
${{ secrets.DOCKERHUB_USERNAME }}/mysql-ch-replicator:${{ env.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
run: >
ls -la &&
docker compose -f docker-compose-tests.yaml up --force-recreate --no-deps --wait -d &&
sudo docker exec -w /app/ -i `docker ps | grep python | awk '{print $1;}'` python3 -m pytest -x -v -s test_mysql_ch_replicator.py
sudo docker exec -w /app/ -i `docker ps | grep mysql_ch_replicator-replicator | awk '{print $1;}'` python3 -m pytest -x -v -s test_mysql_ch_replicator.py
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.4-slim-bookworm

WORKDIR /app

# Copy requirements files
COPY requirements.txt requirements-dev.txt ./

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir -r requirements-dev.txt

# Copy the application
COPY . .

# Create directory for binlog data
RUN mkdir -p /app/binlog

# Make the main script executable
RUN chmod +x /app/main.py

# Set the entrypoint to the main script
ENTRYPOINT ["/app/main.py"]

# Default command (can be overridden in docker-compose)
CMD ["--help"]
38 changes: 33 additions & 5 deletions docker-compose-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ services:
- 9123:9123
volumes:
- ./tests_override.xml:/bitnami/clickhouse/etc/conf.d/override.xml:ro
healthcheck:
test: ["CMD", "true"]
interval: 5s
timeout: 1s
retries: 1
start_period: 15s

mysql_db:
image: mysql:8.4.3
Expand All @@ -30,6 +36,12 @@ services:
- ./test_mysql.cnf:/etc/mysql/my.cnf:ro
networks:
- default
healthcheck:
test: ["CMD", "true"]
interval: 5s
timeout: 1s
retries: 1
start_period: 15s

mariadb_db:
image: mariadb:11.5.2
Expand All @@ -43,15 +55,31 @@ services:
- 9307:3306
volumes:
- ./test_mariadb.cnf:/etc/mysql/my.cnf:ro # Adjust path to MariaDB config location if needed
healthcheck:
test: ["CMD", "true"]
interval: 5s
timeout: 1s
retries: 1
start_period: 15s

replicator:
image: python:3.12.4-slim-bookworm
command: bash -c "pip install -r /app/requirements.txt && pip install -r /app/requirements-dev.txt && touch /tmp/ready && tail -f /dev/null"
build:
context: .
dockerfile: Dockerfile
network_mode: host
volumes:
- ./:/app/
entrypoint: ["/bin/bash"]
command: ["-c", "touch /tmp/ready && tail -f /dev/null"]
healthcheck:
test: [ 'CMD-SHELL', 'test -f /tmp/ready' ]
interval: 2s
retries: 100
start_period: 10s
network_mode: host
volumes:
- ./:/app/
depends_on:
clickhouse_db:
condition: service_healthy
mysql_db:
condition: service_healthy
mariadb_db:
condition: service_healthy