Skip to content

Instantly share code, notes, and snippets.

@minhphong306
Created July 4, 2024 14:34
Show Gist options
  • Save minhphong306/dbc7aa576022ddaa7a2b73eb5a1e02f4 to your computer and use it in GitHub Desktop.
Save minhphong306/dbc7aa576022ddaa7a2b73eb5a1e02f4 to your computer and use it in GitHub Desktop.
selenium dockerfile
# Sử dụng hình ảnh Maven chính thức làm hình ảnh cha
FROM maven:3.8.1-openjdk-11-slim
# Đặt thư mục làm việc trong container
WORKDIR /app
# Sao chép nội dung thư mục hiện tại vào container tại /app
COPY . /app
# Cài đặt cron
RUN apt-get update && apt-get install -y cron
# Tạo file crontab và thêm nhiệm vụ chạy mỗi giờ
RUN echo "0 * * * * root cd /app && mvn test > /proc/1/fd/1 2>/proc/1/fd/2" > /etc/cron.d/selenium-cron
# Cấp quyền thực thi cho crontab
RUN chmod 0644 /etc/cron.d/selenium-cron
# Áp dụng crontab
RUN crontab /etc/cron.d/selenium-cron
# Tạo thư mục log cho cron
RUN touch /var/log/cron.log
# Chạy cron trong foreground
CMD cron && tail -f /var/log/cron.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment