diff --git a/kubernetes/cleanup-pvc.yaml b/kubernetes/cleanup-pvc.yaml new file mode 100644 index 0000000..01d6547 --- /dev/null +++ b/kubernetes/cleanup-pvc.yaml @@ -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 diff --git a/scripts/Dockerfile b/scripts/Dockerfile new file mode 100644 index 0000000..039f70e --- /dev/null +++ b/scripts/Dockerfile @@ -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"] diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh new file mode 100644 index 0000000..ed99dac --- /dev/null +++ b/scripts/cleanup.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# find and delete files older than 7 days +find /srv/results/ -type f -mtime +7 -exec rm -f {} \;