Second commit
This commit is contained in:
parent
239cc86ff4
commit
64b07e74f7
1 changed files with 36 additions and 0 deletions
36
Dockerfile
Normal file
36
Dockerfile
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# Usar uma imagem base oficial do Python
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Instalar dependências do sistema, incluindo nano, curl e cron
|
||||
RUN apt-get update && apt-get install -y \
|
||||
nano \
|
||||
curl \
|
||||
cron \
|
||||
&& apt-get clean
|
||||
|
||||
# Criar diretório da aplicação
|
||||
WORKDIR /app
|
||||
|
||||
# Copiar arquivos da aplicação
|
||||
COPY . /app
|
||||
|
||||
# Instalar dependências do Python
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Criar arquivo de cron que executa o script a cada 2 minutos
|
||||
RUN echo "*/2 * * * * python /app/main.py >> /var/log/cron.log 2>&1" > /etc/cron.d/cronjob
|
||||
|
||||
# Dar permissão para o cron job
|
||||
RUN chmod 0644 /etc/cron.d/cronjob
|
||||
|
||||
# Registrar o cron job
|
||||
RUN crontab /etc/cron.d/cronjob
|
||||
|
||||
# Criar arquivo de log
|
||||
RUN touch /var/log/cron.log
|
||||
|
||||
# Expor porta (caso queira usar FastAPI também)
|
||||
EXPOSE 8000
|
||||
|
||||
# Comando final: iniciar o cron e manter o container ativo
|
||||
CMD cron && tail -f /var/log/cron.log
|
||||
Loading…
Add table
Reference in a new issue