Skip to content

Commit

Permalink
Delete old files from the export app
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosribas committed Aug 1, 2024
1 parent 34861cd commit f69b57d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
21 changes: 21 additions & 0 deletions kubernetes/cleanup-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: file-cleanup
spec:
schedule: "0 0 * * *" # Run daily at midnight
jobTemplate:
spec:
template:
spec:
containers:
- name: cleanup
image: rnacentral/cleanup:latest
volumeMounts:
- name: export-results
mountPath: /srv/results
volumes:
- name: export-results
persistentVolumeClaim:
claimName: export-results
restartPolicy: OnFailure
24 changes: 24 additions & 0 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#-------------------------------------------------------------------------------
#
# The purpose of this Dockerfile is to delete old files from the export app
#
# Commands use to build and push:
#
# docker buildx create --use
# docker buildx build --platform linux/amd64,linux/arm64 -t rnacentral/cleanup:latest --push .
#
#-------------------------------------------------------------------------------

FROM alpine:latest

# install findutils
RUN apk --no-cache add findutils

# add the cleanup script
COPY cleanup.sh /usr/local/bin/cleanup.sh

# make the script executable
RUN chmod +x /usr/local/bin/cleanup.sh

# run the script
CMD ["/usr/local/bin/cleanup.sh"]
4 changes: 4 additions & 0 deletions scripts/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# find and delete files older than 7 days
find /srv/results/ -type f -mtime +7 -exec rm -f {} \;

0 comments on commit f69b57d

Please sign in to comment.