Skip to content

Commit

Permalink
Export K8S logs for API
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvain-morin committed Jun 20, 2024
1 parent 5867814 commit af03f4b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/CICD-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/inaturalistapi:${{ github.ref_name }}

- name: Build/Push Dev inaturalistapi-cleanup
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile-cleanup
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/inaturalistapi-cleanup:${{ github.ref_name }}

refresh-dev-staging-deployment:
name: Refresh Dev Staging Deployment
needs: build-and-push-dev-docker-image
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/CICD-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ jobs:
${{ secrets.DOCKERHUB_USERNAME }}/inaturalistapi:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/inaturalistapi:latest
- name: Build/Push Main inaturalistapi-cleanup
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile-cleanup
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/inaturalistapi-cleanup:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/inaturalistapi-cleanup:latest
refresh-main-staging-deployment:
name: Refresh Main Staging Deployment
needs: build-and-push-main-docker-image
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile-cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest

RUN apk add --no-cache logrotate

RUN mkdir -p /var/api/log
RUN mkdir -p /var/api/script

# Configure logrotate hourly
COPY docker/logrotate.conf /var/api/script/logrotate.conf
COPY docker/logrotate-cron.sh /var/api/script/logrotate-cron.sh
RUN chmod 400 /var/api/script/logrotate.conf
RUN crontab -l | { cat; echo "0 * * * * sh /var/api/script/logrotate-cron.sh"; } | crontab -

# Run cron
CMD ["/bin/sh", "-c", "crond -f"]
2 changes: 2 additions & 0 deletions docker/logrotate-cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/usr/sbin/logrotate -s /var/api/script/logrotate.status /var/api/script/logrotate.conf
10 changes: 10 additions & 0 deletions docker/logrotate.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/var/api/log/logstash.log {
hourly
rotate 5
size 10M
missingok
compress
delaycompress
notifempty
copytruncate
}

0 comments on commit af03f4b

Please sign in to comment.