Compare commits
4 commits
694c4ff93c
...
27a1025eba
Author | SHA1 | Date | |
---|---|---|---|
27a1025eba | |||
348a404288 | |||
697ce20234 | |||
8f3eaa6e2f |
7 changed files with 92 additions and 13 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/output/*
|
17
Dockerfile
17
Dockerfile
|
@ -1,4 +1,4 @@
|
||||||
FROM golang:1.13 AS builder
|
FROM golang:1.14 AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go.mod go.sum /app/
|
COPY go.mod go.sum /app/
|
||||||
|
@ -6,18 +6,13 @@ RUN go mod download
|
||||||
COPY *go /app/
|
COPY *go /app/
|
||||||
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -tags netgo -o /sendmail ./...
|
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -tags netgo -o /sendmail ./...
|
||||||
|
|
||||||
|
FROM busybox:latest AS shell
|
||||||
|
|
||||||
FROM gcr.io/distroless/static
|
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 /
|
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"]
|
||||||
|
|
34
Makefile
Normal file
34
Makefile
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
VERS_MAJOR := 0
|
||||||
|
VERS_MINOR := 3
|
||||||
|
VERSION := $(VERS_MAJOR).$(VERS_MINOR)
|
||||||
|
NEW_MINOR := $$(( $(VERS_MINOR) + 1 ))
|
||||||
|
NEW_MAJOR := $$(( $(VERS_MAJOR) + 1 ))
|
||||||
|
|
||||||
|
output:
|
||||||
|
|
||||||
|
output/sendmail: output
|
||||||
|
go build -o output/sendmail -ldflags "-X main.version=$(VERSION)" ./...
|
||||||
|
|
||||||
|
build: output/sendmail
|
||||||
|
|
||||||
|
bumpvers-minor:
|
||||||
|
sed -i"" "s/VERS_MINOR := $(VERS_MINOR)/VERS_MINOR := $(NEW_MINOR)/" Makefile
|
||||||
|
git add Makefile
|
||||||
|
git commit -m "Bump version $(VERSION) -> $(VERS_MAJOR).$(NEW_MINOR)"
|
||||||
|
git tag $(VERS_MAJOR).$(NEW_MINOR)
|
||||||
|
|
||||||
|
bumpvers-major:
|
||||||
|
sed -i"" "s/VERS_MAJOR := $(VERS_MAJOR)/VERS_MAJOR := $$(( $(VERS_MAJOR) + 1 ))/" Makefile
|
||||||
|
git add Makefile
|
||||||
|
git commit -m "Bump version $(VERSION) -> $(NEW_MAJOR).$(VERS_MINOR)"
|
||||||
|
git tag $(NEW_MAJOR).$(VERS_MINOR)
|
||||||
|
|
||||||
|
release-min:
|
||||||
|
make bumpvers-minor
|
||||||
|
make build
|
||||||
|
|
||||||
|
release-maj:
|
||||||
|
make bumpvers-major
|
||||||
|
make build
|
||||||
|
|
||||||
|
PHONY: bumpvers-minor bumpvers-major release-min release-maj
|
11
docker_test.sh
Executable file
11
docker_test.sh
Executable file
|
@ -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
|
16
examples/sendmail.toml
Normal file
16
examples/sendmail.toml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[default]
|
||||||
|
from = "my.default@example.com"
|
||||||
|
|
||||||
|
[default.server]
|
||||||
|
address = "mail.example.com"
|
||||||
|
port = 587
|
||||||
|
user = "my.default@example.com"
|
||||||
|
password = "correcthorsebatterystaple"
|
||||||
|
|
||||||
|
[other-account]
|
||||||
|
from = "my.other@mailprovider.org"
|
||||||
|
|
||||||
|
[ai.server]
|
||||||
|
address = "smtp.mailprovider.org"
|
||||||
|
port = 587
|
||||||
|
user = "my.correct.username@mailprovider.org"
|
9
main.go
9
main.go
|
@ -8,7 +8,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "0.1"
|
var noVersion = "dev"
|
||||||
|
var version string
|
||||||
|
|
||||||
func readFromConsole() string {
|
func readFromConsole() string {
|
||||||
var text, line string
|
var text, line string
|
||||||
|
@ -90,7 +91,11 @@ func main() {
|
||||||
LogInit(dbg)
|
LogInit(dbg)
|
||||||
|
|
||||||
if versionFlag {
|
if versionFlag {
|
||||||
Info.F("Version: %s", version)
|
showVersion := noVersion
|
||||||
|
if version != "" {
|
||||||
|
showVersion = version
|
||||||
|
}
|
||||||
|
Info.F("Version: %s", showVersion)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
sendmail.sh
Executable file
17
sendmail.sh
Executable file
|
@ -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
|
Loading…
Reference in a new issue