Minor changes in Docker container
This commit is contained in:
+31
-9
@@ -14,9 +14,20 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
|||||||
# the application crashes without emitting any logs due to buffering.
|
# the application crashes without emitting any logs due to buffering.
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
# Install additional binary packages.
|
# Install required binary packages.
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
imagemagick \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Add PDF processing to the ImageMagic policy.
|
||||||
|
RUN sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/g' /etc/ImageMagick-6/policy.xml
|
||||||
|
|
||||||
|
# DEBUG. Only for debug purposes.
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
curl \
|
curl \
|
||||||
|
procps \
|
||||||
|
sudo \
|
||||||
|
vim \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -24,14 +35,22 @@ WORKDIR /app
|
|||||||
# Create a non-privileged user that the app will run under.
|
# Create a non-privileged user that the app will run under.
|
||||||
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
|
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
|
||||||
ARG UID=10001
|
ARG UID=10001
|
||||||
RUN adduser \
|
#RUN adduser \
|
||||||
--disabled-password \
|
# --disabled-password \
|
||||||
--gecos "" \
|
# --gecos "" \
|
||||||
--home "/nonexistent" \
|
# --home "/nonexistent" \
|
||||||
--shell "/sbin/nologin" \
|
# --shell "/sbin/nologin" \
|
||||||
--no-create-home \
|
# --no-create-home \
|
||||||
--uid "${UID}" \
|
# --uid "${UID}" \
|
||||||
appuser
|
# appuser
|
||||||
|
|
||||||
|
# DEBUG. Only for debug purposes.
|
||||||
|
RUN useradd -r -u ${UID} -s /sbin/nologin -d /nonexistent appuser
|
||||||
|
RUN echo "appuser:12345678" | chpasswd
|
||||||
|
RUN echo 'appuser ALL=(ALL) NOPASSWD:ALL' | tee -a /etc/sudoers
|
||||||
|
|
||||||
|
# Upgrade pip
|
||||||
|
RUN python -m pip install --upgrade pip
|
||||||
|
|
||||||
# Download dependencies as a separate step to take advantage of Docker's caching.
|
# Download dependencies as a separate step to take advantage of Docker's caching.
|
||||||
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
||||||
@@ -47,6 +66,9 @@ USER appuser
|
|||||||
# Copy the source code into the container.
|
# Copy the source code into the container.
|
||||||
COPY --chown=appuser . .
|
COPY --chown=appuser . .
|
||||||
|
|
||||||
|
# Change file mode(s).
|
||||||
|
RUN chmod 0744 cron.sh
|
||||||
|
|
||||||
# Expose the port that the application listens on.
|
# Expose the port that the application listens on.
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
python3 /app/arxiv_daemon.py --num 100
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "New papers detected! Running compute.py"
|
||||||
|
python3 /app/compute.py
|
||||||
|
else
|
||||||
|
echo "No new papers were added, skipping feature computation"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Edit this file to introduce tasks to be run by cron.
|
||||||
|
#
|
||||||
|
# Each task to run has to be defined through a single line
|
||||||
|
# indicating with different fields when the task will be run
|
||||||
|
# and what command to run for the task
|
||||||
|
#
|
||||||
|
# To define the time you can provide concrete values for
|
||||||
|
# minute (m), hour (h), day of month (dom), month (mon),
|
||||||
|
# and day of week (dow) or use '*' in these fields (for 'any').#
|
||||||
|
# Notice that tasks will be started based on the cron's system
|
||||||
|
# daemon's notion of time and timezones.
|
||||||
|
#
|
||||||
|
# Output of the crontab jobs (including errors) is sent through
|
||||||
|
# email to the user the crontab file belongs to (unless redirected).
|
||||||
|
#
|
||||||
|
# For example, you can run a backup of all your user accounts
|
||||||
|
# at 5 a.m every week with:
|
||||||
|
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
|
||||||
|
#
|
||||||
|
# For more information see the manual pages of crontab(5) and cron(8)
|
||||||
|
#
|
||||||
|
# m h dom mon dow command
|
||||||
|
*/1 * * * * /app/cron.sh
|
||||||
|
*/1 * * * * echo Hello
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "Docker container has been started"
|
||||||
|
|
||||||
|
cron && tail -f /var/log/cron.log
|
||||||
|
export FLASK_APP=serve.py; flask run --host=0.0.0.0
|
||||||
|
# sudo crontab cronjob
|
||||||
|
# sudo cron -f
|
||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
feedparser
|
feedparser
|
||||||
Flask
|
flask
|
||||||
numpy
|
numpy
|
||||||
|
requests
|
||||||
scikit-learn
|
scikit-learn
|
||||||
sqlitedict
|
sqlitedict
|
||||||
|
|||||||
Reference in New Issue
Block a user