Skip to content

updated Dockerfile and compose to include ENV crons #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ FROM gameservermanagers/linuxgsm:{{ distro }}
LABEL maintainer="LinuxGSM <[email protected]>"
ARG SHORTNAME={{ shortname }}
ENV GAMESERVER={{ shortname }}server
# Default cron schedules (can be overridden in docker-compose)
ENV MONITOR_CRON="*/5 * * * *"
ENV UPDATE_CRON="*/30 * * * *"
ENV FORCE_UPDATE_CRON="30 4 * * *"
ENV UPDATE_LGSM_CRON="0 0 * * 0"
ENV BACKUP_CRON="0 5 * * *"

WORKDIR /app

Expand All @@ -16,12 +22,25 @@ RUN depshortname=$(curl --connect-timeout 10 -s https://raw.githubusercontent.co
&& if [ -n "${depshortname}" ]; then \
echo "**** Install ${depshortname} ****" \
&& apt-get update \
&& apt-get install -y ${depshortname} \
&& apt-get install -y ${depshortname} cron \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \
fi

# Set up cron jobs dynamically based on environment variables
RUN echo "Setting up cron jobs" \
&& echo "$MONITOR_CRON /app/$GAMESERVER monitor > /dev/null 2>&1" >> /etc/crontab \
&& echo "$UPDATE_CRON /app/$GAMESERVER update > /dev/null 2>&1" >> /etc/crontab \
&& echo "$FORCE_UPDATE_CRON /app/$GAMESERVER force-update > /dev/null 2>&1" >> /etc/crontab \
&& echo "$UPDATE_LGSM_CRON /app/$GAMESERVER update-lgsm > /dev/null 2>&1" >> /etc/crontab \
&& echo "$BACKUP_CRON /app/$GAMESERVER backup > /dev/null 2>&1" >> /etc/crontab \
&& chmod 0644 /etc/crontab \
&& crontab /etc/crontab

# Run cron in the background
RUN service cron start

HEALTHCHECK --interval=1m --timeout=1m --start-period=2m --retries=1 CMD /app/entrypoint-healthcheck.sh || exit 1

RUN date > /build-time.txt
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ services:
image: gameservermanagers/gameserver:{{ shortname }}
# image: ghcr.io/gameservermanagers/gameserver:{{ shortname }}
container_name: {{ shortname }}server
environment:
# Cron job environment variables
MONITOR_CRON: "*/5 * * * *"
UPDATE_CRON: "*/30 * * * *"
FORCE_UPDATE_CRON: "30 4 * * *"
UPDATE_LGSM_CRON: "0 0 * * 0"
BACKUP_CRON: "0 5 * * *"
restart: unless-stopped
volumes:
- /path/to/linuxgsm/{{ shortname }}server:/data
Expand All @@ -15,6 +22,13 @@ services:
image: gameservermanagers/gameserver:{{ shortname }}
# image: ghcr.io/gameservermanagers/gameserver:{{ shortname }}
container_name: {{ shortname }}server
environment:
# Cron job environment variables
MONITOR_CRON: "*/5 * * * *"
UPDATE_CRON: "*/30 * * * *"
FORCE_UPDATE_CRON: "30 4 * * *"
UPDATE_LGSM_CRON: "0 0 * * 0"
BACKUP_CRON: "0 5 * * *"
restart: unless-stopped
volumes:
- linuxgsm-{{ shortname }}:/data
Expand Down