Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
use an entrypoint script that starts a cronjob to run every minute
Browse files Browse the repository at this point in the history
  • Loading branch information
fczuardi committed Jan 11, 2024
1 parent 1ff020e commit e5cd47f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set +x

# Create a cron job that runs every minute
echo "* * * * * /app/run_tests.sh" > /etc/crontabs/root

# Start cron
crond -f &

# Start Nginx
exec nginx -g 'daemon off;'

2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

printf ":-)\n\nTests started on $(date)" > results/smile.txt
printf ":-)\n\nTests started on $(date)" > /app/results/smile.txt
17 changes: 11 additions & 6 deletions webapp.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Use main image as base
FROM ghcr.io/marmotitude/object-storage-tests:main

# Install Nginx
# Install Nginx and cron
RUN apk update && \
apk add nginx
apk add --no-cache nginx dcron

# Keep a backup of alpine's default nginx config
RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
Expand All @@ -22,7 +22,7 @@ RUN chown -R root:root results && \
chmod -R 755 results

# Write dummy file to results directory with a smile and timestamp
RUN printf ":-)\n\nBuilded on $(date) by:$(hostname)" > results/smile.txt
RUN printf ":-)\n\nBuilt on $(date) by:$(hostname)" > results/smile.txt

# Copy the shell script that runs desired tests outputing to results folder
# this script will be executed by an external scheduler periodically
Expand All @@ -31,6 +31,11 @@ COPY run_tests.sh /app/run_tests.sh
# Expose port 5000
EXPOSE 5000

# Override the main image's entry point and set the default command
ENTRYPOINT ["nginx", "-g", "daemon off;"]
CMD []
# Copy the entrypoint script
COPY entrypoint.sh /app/entrypoint.sh

# Make the script executable
RUN chmod +x /app/entrypoint.sh

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

0 comments on commit e5cd47f

Please sign in to comment.