diff --git a/Dockerfile b/Dockerfile index d458464..6325d7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use the official Python image from the Docker Hub -FROM python:3.12 +FROM python:3.12-alpine # Set the working directory in the container WORKDIR /app @@ -10,24 +10,21 @@ COPY requirements.txt /app/ # Install the package dependencies RUN pip install --no-cache-dir -r requirements.txt -# Install cron -RUN apt-get update && apt-get install -y cron +# Install supercronic +RUN apk add curl +# Latest releases available at https://github.com/aptible/supercronic/releases +ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.33/supercronic-linux-amd64 \ + SUPERCRONIC_SHA1SUM=71b0d58cc53f6bd72cf2f293e09e294b79c666d8 \ + SUPERCRONIC=supercronic-linux-amd64 +RUN curl -fsSLO "$SUPERCRONIC_URL" \ + && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ + && chmod +x "$SUPERCRONIC" \ + && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ + && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic # Copy the rest of the application code into the container COPY . /app/ -# Copy the cron job file into the container -COPY cron-jobs /etc/cron.d/cron-jobs - -# Give execution rights on the cron job -RUN chmod 0644 /etc/cron.d/cron-jobs - -# Apply cron job -RUN crontab /etc/cron.d/cron-jobs - -# Create a cron log file to be able to run `tail` -RUN touch /var/log/cron.log - # Don't buffer log output to stdout ENV PYTHONUNBUFFERED 1 diff --git a/entrypoint.sh b/entrypoint.sh index 68de9b0..c3b28a6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,8 +7,8 @@ python manage.py makemigrations matcher python manage.py migrate python manage.py createsuperuser --no-input -# Start the cron service -service cron start +# Start supercronic +supercronic /app/cron-jobs # Start Gunicorn server exec gunicorn meetups.wsgi:application --bind 0.0.0.0:$PORT