4
4
# https://hub.docker.com/_/node
5
5
FROM node:lts-alpine
6
6
7
- # Add cURL for health check and OpenSSL for generating random secret
8
- RUN apk update && apk add --no-cache curl openssl
7
+ # Add cURL for health check, OpenSSL for generating random secret
8
+ # and SuperCronic for cronjobs
9
+ RUN apk update && apk add --no-cache curl openssl supercronic
9
10
10
11
# Set the working directory to the website files
11
12
WORKDIR /usr/src/app
@@ -25,6 +26,11 @@ RUN --mount=type=cache,target=.npm \
25
26
npm set cache .npm && \
26
27
npm install && chown -R node:node ./node_modules
27
28
29
+ # Add some cronjobs for automated tasks
30
+ RUN npx tsc scripts/create-fake-accounts.ts scripts/expired-files.ts scripts/outdated-notifications.ts
31
+ RUN echo "*/5 * * * * node /usr/src/app/scripts/expired-files.js > /dev/null 2>&1" >> /var/spool/cron/crontabs/node
32
+ RUN echo "*/5 * * * * node /usr/src/app/scripts/outdated-notifications > /dev/null 2>&1" >> /var/spool/cron/crontabs/node
33
+
28
34
# Add wait script to wait for other services to be ready
29
35
ADD https://github.com/ufoscout/docker-compose-wait/releases/latest/download/wait /wait
30
36
RUN chmod +x /wait
@@ -36,6 +42,6 @@ USER node
36
42
RUN sed -i "s#AUTH_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#AUTH_SECRET=$(openssl rand -base64 32)#g" .env
37
43
38
44
# Create a custom entrypoint script
39
- RUN echo "/wait && npm run migrate && npm run dev" > docker/entrypoint.sh && chmod +x docker/entrypoint.sh
45
+ RUN echo "/wait && npm run migrate && node scripts/create-fake-accounts.js && supercronic /etc/crontabs/node && npm run dev" > docker/entrypoint.sh && chmod +x docker/entrypoint.sh
40
46
41
47
CMD ["docker/entrypoint.sh"]
0 commit comments