Skip to content

Commit

Permalink
allow nearbeach user to run cron
Browse files Browse the repository at this point in the history
this allows the container to run a non-root user
  • Loading branch information
nearlynocturnalbeach committed Dec 2, 2024
1 parent 178081e commit 0c836b6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ RUN echo "**** install NearBeach Latest ****" && \
pip install NearBeach

RUN echo "**** copy over the crontab configuration ****"
COPY crontab /etc/crontabs/root
COPY --chown=nearbeach:nearbeach crontab /etc/crontabs/nearbeach

RUN echo "**** setup of working directory ****"
WORKDIR /oceansuite
RUN chown nearbeach:nearbeach /oceansuite
#USER nearbeach

USER nearbeach

RUN echo "**** copy everything into the destination ****"
COPY --chown=nearbeach:nearbeach . .
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ RUN echo "**** install build packages ****" && \
tini \
tk-dev \
zlib-dev
dcron \
libcap

RUN echo "**** allow nearbeach user to run cron ****" && \
chown nearbeach:nearbeach /usr/sbin/crond && \
setcap cap_setgid=ep /usr/sbin/crond

ARG TARGET_BRANCH=main
# Copy the requirements.txt file
Expand Down
4 changes: 3 additions & 1 deletion oceansuite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
}


# CRONTAB_TIMESTR="0 0 * * *"

# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

Expand Down Expand Up @@ -171,7 +173,7 @@
STATIC_URL = '/static/'
else:
STATIC_URL = F"https://cdn.nearbeach.org/{VERSION}/"

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR,'media/')

Expand Down
7 changes: 5 additions & 2 deletions setup_db_and_run_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ python manage.py migrate
python manage.py initadmin
echo "**** DB setup complete ****"

echo "**** Updating Crontab ****"
python manage.py updatecrontab

echo "**** Starting Cron Services ****"
crond
crond -b -l 8

echo "**** running NearBeach ****"
python manage.py runserver 0.0.0.0:8000
python manage.py runserver 0.0.0.0:8000

0 comments on commit 0c836b6

Please sign in to comment.