create nginx service and add Dcokerfilewith cerbot

This commit is contained in:
2025-05-26 19:35:50 +03:00
parent 34f445132c
commit c197427ab8
7 changed files with 161 additions and 5 deletions
+25
View File
@@ -0,0 +1,25 @@
FROM nginx:latest
# Устанавливаем Certbot и зависимости
RUN apt-get update && \
apt-get install -y certbot python3-certbot-nginx cron && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Удаляем дефолтный конфиг Nginx
RUN rm /etc/nginx/conf.d/default.conf
# Копируем ваш Nginx-конфиг и скрипты
COPY yalarba.ru.conf /etc/nginx/conf.d/
COPY startup.sh /usr/local/bin/
COPY renew-certs.sh /usr/local/bin/
# Даем права на выполнение скриптов
RUN chmod +x /usr/local/bin/startup.sh /usr/local/bin/renew-certs.sh
# Добавляем cron-задачу для обновления сертификатов
RUN echo "0 3 * * * /usr/local/bin/renew-certs.sh >> /var/log/cron.log 2>&1" > /etc/cron.d/certbot-renew
RUN chmod 0644 /etc/cron.d/certbot-renew
# Запускаем cron и Nginx при старте
CMD ["/usr/local/bin/startup.sh"]