[컴] nodejs application with Docker

 노드 / 도커 / docker-compose /composer / compose

nodejs application with Docker

crontab 으로 주기적으로 node application 을 run 하게 하려한다.

$ sudo docker build -t my-nodejs-app .

...

$ sudo docker run -t my-node-app2

Best pratices for docker-node

  1. docker-node/BestPractices.md at main · nodejs/docker-node · GitHub

docker-compose

Dockerfile

FROM node:14

ENV USERHOME=/home/node

RUN apt-get update && apt-get install -y cron mysql-client


# install node app
COPY --chown=node:node index.js /home/node/ 
COPY --chown=node:node package.json /home/node/

# cron tab
COPY dbzipper-crontab /etc/cron.d/dbzipper-crontab
RUN chmod +x /etc/cron.d/dbzipper-crontab

RUN crontab /etc/cron.d/dbzipper-crontab

CMD ["cron", "-f"]

See Also

  1. How to run a cron job inside a docker container? - Stack Overflow

Reference

  1. Scheduling background tasks using cron in a Docker container
  2. docker-node/README.md at main · nodejs/docker-node · GitHub
  3. GitHub - robogeek/docker-cron: Docker container for managing cron jobs
  4. Overview of Docker Compose | Docker Documentation

댓글 없음:

댓글 쓰기