diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 54dbe92..c29df6e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,7 +7,13 @@ on: push: branches: [main] paths: - - 'tmfeed/feedforbot.config.yml' + - 'tmfeed/**' + workflow_dispatch: + inputs: + image_tag: + description: 'feedforbot image tag to deploy (default: latest)' + required: false + default: '' jobs: build: @@ -86,6 +92,7 @@ jobs: && (needs.build.result == 'success' || needs.build.result == 'skipped') && ( github.event_name == 'push' + || github.event_name == 'workflow_dispatch' || !contains(github.event.release.tag_name, 'rc') ) steps: @@ -97,6 +104,8 @@ jobs: run: | if [ "${{ github.event_name }}" = "release" ]; then echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT" + elif [ -n "${{ github.event.inputs.image_tag }}" ]; then + echo "tag=${{ github.event.inputs.image_tag }}" >> "$GITHUB_OUTPUT" else echo "tag=latest" >> "$GITHUB_OUTPUT" fi diff --git a/tmfeed/deploy.playbook.yml b/tmfeed/deploy.playbook.yml index 6c532dd..25046b1 100644 --- a/tmfeed/deploy.playbook.yml +++ b/tmfeed/deploy.playbook.yml @@ -35,6 +35,24 @@ state: started enabled: true + - name: Configure Docker daemon log rotation + become: true + copy: + dest: /etc/docker/daemon.json + content: | + { + "log-driver": "json-file", + "log-opts": { + "max-size": "10m", + "max-file": "3" + } + } + mode: "0644" + notify: Restart docker + + - name: Apply Docker daemon changes before starting containers + meta: flush_handlers + - name: Add user to docker group become: true user: @@ -129,3 +147,10 @@ - name: Show docker compose ps debug: var: compose_status.stdout_lines + + handlers: + - name: Restart docker + become: true + systemd: + name: docker + state: restarted diff --git a/tmfeed/feedforbot.compose.yml.j2 b/tmfeed/feedforbot.compose.yml.j2 index 9341ca4..d4a55e9 100644 --- a/tmfeed/feedforbot.compose.yml.j2 +++ b/tmfeed/feedforbot.compose.yml.j2 @@ -6,6 +6,11 @@ services: volumes: - ./redis_data:/data command: ["redis-server", "--save", "60", "1", "--appendonly", "no"] + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s @@ -23,6 +28,11 @@ services: volumes: - ./config.yml:/config.yml:ro command: -v --cache-dsn redis://redis:6379/0 --healthcheck-port 8080 {{ ('--sentry ' + feedforbot_sentry) if feedforbot_sentry != '' else '' }} /config.yml + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3" healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health')"] interval: 30s