Skip to content

Commit

Permalink
chore: Setup cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
shonenada committed Feb 22, 2019
1 parent 52820ff commit 76dde3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARG commit
ARG version

ENV WORKSPACE /workspace
ENV PYTHONPATH="$WORKSPACE"
ENV STALLS_HOST="localhost"
ENV STALLS_PORT="5000"
ENV STALLS_GUNICORN_WORKERS="1"
Expand All @@ -13,19 +14,22 @@ ENV STALLS_BABEL_TRANSLATION_DIRECTORIES="$WORKSPACE/stalls/translations"
RUN mkdir $WORKSPACE
WORKDIR $WORKSPACE

# Generate version and build information
RUN echo "$version" >> $WORKSPACE/version
RUN echo "$commit" >> $WORKSPACE/commit
RUN echo "$build_date" >> $WORKSPACE/build_date

COPY ./entrypoint.sh /entrypoint.sh
COPY ./requirements.txt /tmp/requirements.txt
COPY ./component $WORKSPACE/component
COPY ./stalls $WORKSPACE/stalls
COPY ./deploy $WORKSPACE/deploy

RUN pip install -r /tmp/requirements.txt -i https://pypi.douban.com/simple
RUN pip install gunicorn

# Generate version and build information
RUN echo "$version" >> $WORKSPACE/version
RUN echo "$commit" >> $WORKSPACE/commit
RUN echo "$build_date" >> $WORKSPACE/build_date
RUN pip install -r /tmp/requirements.txt -i https://pypi.douban.com/simple \
&& pip install gunicorn \
&& chmod +x /entrypoint.sh

ENTRYPOINT ["/usr/local/bin/gunicorn"]
RUN echo "* * * * * python $WORKSPACE/scripts/cron/notify_expired.py 2>&1 >> $WORKSPACE/cronjob.log" > /etc/crontabs/root

CMD [ "-c", "/workspace/deploy/gunicorn_conf.py", "stalls.wsgi:application" ]
ENTRYPOINT "/entrypoint.sh"
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

crond -b

cd $WORKSPACE && /usr/local/bin/gunicorn -c $WORKSPACE/deploy/gunicorn_conf.py stalls.wsgi:application

0 comments on commit 76dde3e

Please sign in to comment.