Skip to content

Commit

Permalink
update docker container to use alpine linux + supercronic
Browse files Browse the repository at this point in the history
  • Loading branch information
liddiard committed Dec 25, 2024
1 parent ac873a8 commit 11ac053
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
27 changes: 12 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 11ac053

Please sign in to comment.