Skip to content

Instantly share code, notes, and snippets.

@refracta
Created June 22, 2024 17:04
Show Gist options
  • Save refracta/559e91a9d4686624556a6733c2191cdf to your computer and use it in GitHub Desktop.
Save refracta/559e91a9d4686624556a6733c2191cdf to your computer and use it in GitHub Desktop.
cron-example
version: '3'
services:
  node:
    build: .
    volumes:
      - .:/usr/src
    working_dir: /usr/src
    restart: unless-stopped
    shm_size: 256M
    command: >
      /bin/sh -c "if [ ! -d node_modules ]; then npm install; fi &&
      (
      echo '0 17 * * 0 /bin/bash -c \"cd /usr/src && /usr/local/bin/node index.js /usr/src/config.json  >> /usr/src/cron.log 2>&1\"';
      echo '0 18 * * * /bin/bash -c \"cd /usr/src && /usr/local/bin/node index.js /usr/src/config.json >> /usr/src/cron.log 2>&1\"';
      echo '0 19 * * * /bin/bash -c \"cd /usr/src && /usr/local/bin/node index.js /usr/src/config.json  >> /usr/src/cron.log 2>&1\"';
      ) | crontab - &&
      cron -f"      
FROM node:14

WORKDIR /usr/src
ENV TZ=Asia/Seoul
RUN apt-get -y update && apt install wget unzip cron tzdata -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment