simplify and modernise setup
This commit is contained in:
@@ -5,12 +5,11 @@
|
||||
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
type: docker
|
||||
|
||||
steps:
|
||||
- name: reuse
|
||||
image: fsfe/reuse:latest
|
||||
- name: deploy
|
||||
pull: if-not-exists
|
||||
image: docker/compose:1.29.2
|
||||
@@ -18,7 +17,7 @@ steps:
|
||||
XDG_RUNTIME_DIR: "/run/user/1001"
|
||||
DOCKER_HOST: "unix:///run/user/1001/docker.sock"
|
||||
commands:
|
||||
- docker-compose --project-name reminder-mails up --build -d
|
||||
- docker-compose -p reminder-mails up --build -d
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /run/user/1001/docker.sock
|
||||
|
@@ -8,7 +8,7 @@ auth off
|
||||
tls on
|
||||
tls_starttls on
|
||||
tls_certcheck off
|
||||
logfile /home/reminder/reminder-mails/msmtp.log
|
||||
logfile ~/.msmtp.log
|
||||
|
||||
# FSFE
|
||||
account fsfe
|
49
Dockerfile
49
Dockerfile
@@ -3,42 +3,31 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# Base image selection
|
||||
FROM debian:buster-slim
|
||||
FROM bitnami/minideb:bullseye
|
||||
|
||||
# Installing the services and dependencies
|
||||
ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8 LC_ALL=C.UTF-8 LANGUAGE=en_US.UTF-8
|
||||
RUN [ "apt-get", "-q", "update" ]
|
||||
RUN [ "apt-get", "-qy", "--force-yes", "upgrade" ]
|
||||
RUN [ "apt-get", "install", "--no-install-recommends", "-qy", "--force-yes", \
|
||||
"ca-certificates", \
|
||||
"git", \
|
||||
"cron", \
|
||||
"msmtp" ]
|
||||
RUN [ "apt-get", "clean" ]
|
||||
RUN [ "rm", "-rf", "/var/lib/apt/lists/*", "/tmp/*", "/var/tmp/*" ]
|
||||
RUN install_packages msmtp ca-certificates curl
|
||||
|
||||
RUN adduser --quiet --disabled-password --shell /bin/bash --home /home/reminder --gecos "User" reminder
|
||||
# Manually install supercronic
|
||||
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \
|
||||
SUPERCRONIC=supercronic-linux-amd64 \
|
||||
SUPERCRONIC_SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e
|
||||
|
||||
RUN curl -fsSLO "$SUPERCRONIC_URL" \
|
||||
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
|
||||
&& chmod +x "$SUPERCRONIC" \
|
||||
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
|
||||
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
|
||||
|
||||
RUN adduser --shell "/sbin/nologin" --gecos "Reminder" --disabled-password reminder
|
||||
|
||||
USER reminder
|
||||
|
||||
WORKDIR /home/reminder
|
||||
|
||||
# Add latest master branch version to skip loading from cache if newer commit available
|
||||
ADD https://git.fsfe.org/api/v1/repos/fsfe-system-hackers/reminder-mails/branches/master version.json
|
||||
RUN mkdir mails
|
||||
COPY reminder-mails.sh cron.txt .msmtprc /home/reminder/
|
||||
COPY mails/* /home/reminder/mails/
|
||||
|
||||
RUN git clone https://git.fsfe.org/fsfe-system-hackers/reminder-mails.git
|
||||
|
||||
WORKDIR /home/reminder/reminder-mails
|
||||
|
||||
# First run to create files
|
||||
RUN /home/reminder/reminder-mails/reminder-mails.sh
|
||||
|
||||
# Add crontab file in the cron directory
|
||||
ADD cron.txt /etc/cron.d/reminder-mails
|
||||
|
||||
# Give execution rights on the cron job
|
||||
USER root
|
||||
RUN chmod 0644 /etc/cron.d/reminder-mails
|
||||
|
||||
# CMD to run the service on container start
|
||||
CMD cron && : >> /home/reminder/reminder-mails/app.log && tail -f /home/reminder/reminder-mails/app.log
|
||||
# CMD to run the cron on container start
|
||||
CMD supercronic /home/reminder/cron.txt
|
||||
|
6
cron.txt
6
cron.txt
@@ -2,6 +2,6 @@
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
0 22 15 2,5,8,11 * reminder /home/reminder/reminder-mails/reminder-mails.sh access-review
|
||||
0 22 15 1,4,7,10 * reminder /home/reminder/reminder-mails/reminder-mails.sh services-review
|
||||
0 22 15 3,6,9,12 * reminder /home/reminder/reminder-mails/reminder-mails.sh mailinglist-review
|
||||
0 22 15 2,5,8,11 * /home/reminder/reminder-mails.sh access-review
|
||||
0 22 15 1,4,7,10 * /home/reminder/reminder-mails.sh services-review
|
||||
0 22 15 3,6,9,12 * /home/reminder/reminder-mails.sh mailinglist-review
|
||||
|
@@ -2,19 +2,11 @@
|
||||
|
||||
# This file takes care of identifying the requested mail, adding necessary
|
||||
# information to the template, and piping it to msmtp to send it out.
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2018 Free Software Foundation Europe <contact@fsfe.org>
|
||||
# Author 2018 Max Mehl <max.mehl@fsfe.org>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
basedir="${0%/*}"
|
||||
LOG="${basedir}/app.log"
|
||||
touch "${LOG}"
|
||||
touch "${basedir}/msmtp.log"
|
||||
|
||||
exec > >(tee -ia "${LOG}")
|
||||
exec 2>&1
|
||||
|
||||
function decho {
|
||||
DATE=$(date +%y-%m-%d_%H:%M:%S%z)
|
||||
echo "[$DATE] $*"
|
||||
@@ -24,12 +16,13 @@ EMAIL=$1
|
||||
|
||||
# If argument is given, check for mail template and send it out
|
||||
if [[ ! -z "$EMAIL" ]]; then
|
||||
if [[ -e "${basedir}/mails/$EMAIL" ]]; then
|
||||
cat "${basedir}/mails/$EMAIL" | sed "1s|^|Date: $(date -R)\n|" | sed "1s|^|Message-ID: <ReMiNdEr.$(date +%s)@fsfe.org>\n|" | msmtp -C "${basedir}"/msmtprc -t --read-envelope-from -a fsfe
|
||||
if [[ -e "${HOME}/mails/$EMAIL" ]]; then
|
||||
cat "${HOME}/mails/$EMAIL" | sed "1s|^|Date: $(date -R)\n|" | sed "1s|^|Message-ID: <ReMiNdEr.$(date +%s)@fsfe.org>\n|" | msmtp -t --read-envelope-from -a fsfe
|
||||
if [[ "$?" == 0 ]]; then
|
||||
decho "[INFO] Mail \"$EMAIL\" has been sent successfully"
|
||||
else
|
||||
decho "[ERROR] There has been an error with sending \"$EMAIL\"".
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
decho "[ERROR] Mail template \"$EMAIL\" does not exist."
|
||||
|
3
renovate.json.license
Normal file
3
renovate.json.license
Normal file
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2022 Free Software Foundation Europe <https://fsfe.org>
|
||||
|
||||
SPDX-License-Identifier: CC0-1.0
|
Reference in New Issue
Block a user