From 8f3eaa6e2fce93b03664649da52d53504168af6d Mon Sep 17 00:00:00 2001 From: Blallo Date: Wed, 29 Apr 2020 09:49:24 +0200 Subject: [PATCH] Change docker image --- Dockerfile | 17 ++++++----------- docker_test.sh | 11 +++++++++++ sendmail.sh | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 11 deletions(-) create mode 100755 docker_test.sh create mode 100755 sendmail.sh diff --git a/Dockerfile b/Dockerfile index 922f641..72ac1b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.13 AS builder +FROM golang:1.14 AS builder WORKDIR /app COPY go.mod go.sum /app/ @@ -6,18 +6,13 @@ RUN go mod download COPY *go /app/ RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -tags netgo -o /sendmail ./... +FROM busybox:latest AS shell FROM gcr.io/distroless/static -ENV sm_server "" -ENV sm_port "465" -ENV sm_user "" -ENV sm_password "" -ENV sm_from "" -ENV sm_to "" -ENV sm_sub "" - -COPY --from=builder /sendmail / WORKDIR / +COPY --from=builder /sendmail / +COPY --from=shell /bin/cat /bin/date /bin/sh /bin/ +COPY sendmail.sh /sendmail.sh -ENTRYPOINT ["/sendmail"] +ENTRYPOINT ["/sendmail.sh"] diff --git a/docker_test.sh b/docker_test.sh new file mode 100755 index 0000000..7c36ba3 --- /dev/null +++ b/docker_test.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +docker run \ + -e M_SERVER_ADDRESS=smtp.autistici.org \ + -e M_USER=problemi.ma@anche.no \ + -e M_PASSWORD=$(pass personal/ai/otp/mail/sendmail-stakhanov) \ + -e M_FROM=blallo@autistici.org \ + -e M_TO=blallo@riseup.net \ + -e M_SUB="test mail from docker image" \ + -e M_TEXT="Test from docker image" \ + -ti leophys/sendmail:latest diff --git a/sendmail.sh b/sendmail.sh new file mode 100755 index 0000000..0d0d303 --- /dev/null +++ b/sendmail.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +cat << EOM | /sendmail \ +-server-address=${M_SERVER_ADDRESS} \ +-server-port=465 \ +-user=${M_USER} \ +-password=${M_PASSWORD} \ +-from=${M_FROM} \ +-to=${M_TO} \ +-sub="${M_SUB}" +$(date +%Y-%m-%d_%H:%M) +--- +${M_TEXT} + + + +EOM