diff --git a/.dockerignore b/.dockerignore index 279fc8e..e4adc91 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,6 @@ /vendor /data /bin -/misc/docker +/misc/docker/Dockerfile /.env /.env.dist \ No newline at end of file diff --git a/README.md b/README.md index 2de6bc2..67ec39e 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ L'interface Web sera accessible à l'adresse http://localhost:8080/. Le serveur SMTP sera accessible sur le port 2525. L'authentification est désactivée par défaut. +Voir la section "[Variables d'environnement](#variables-denvironnement)" pour voir comment personnaliser la configuration du service. + ### Avec les binaires > TODO diff --git a/cmd/fake-smtp/smtp.go b/cmd/fake-smtp/smtp.go index 2963f0e..509dacc 100644 --- a/cmd/fake-smtp/smtp.go +++ b/cmd/fake-smtp/smtp.go @@ -43,7 +43,9 @@ func (b *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, err return nil, smtp.ErrAuthRequired } - return nil, nil + ctx := context.WithValue(context.Background(), container.KeyServiceContainer, b.ctn) + + return &Session{ctx, b.ctn, "anonymous"}, nil } // A Session is returned after successful login. @@ -105,6 +107,11 @@ func startSMTPServer(conf *config.Config, ctn *service.Container) { s.MaxMessageBytes = conf.SMTP.MaxMessageBytes s.MaxRecipients = conf.SMTP.MaxRecipients s.AllowInsecureAuth = conf.SMTP.AllowInsecureAuth + + if conf.SMTP.Username == "" && conf.SMTP.Password == "" { + s.AuthDisabled = true + } + if conf.SMTP.Debug { s.Debug = os.Stdout } diff --git a/misc/docker/Dockerfile b/misc/docker/Dockerfile index 32e2447..ac5a441 100644 --- a/misc/docker/Dockerfile +++ b/misc/docker/Dockerfile @@ -14,8 +14,13 @@ COPY . /src WORKDIR /src +RUN cp -f misc/docker/config-patch.yml misc/release/config-patch.yml + +RUN go get github.com/krishicks/yaml-patch/cmd/yaml-patch + RUN npm install \ && make vendor \ + && echo "---" > ./misc/release/config-patch.yml \ && make ARCH_TARGETS=amd64 release FROM busybox @@ -24,4 +29,6 @@ COPY --from=build /src/release/fake-smtp-linux-amd64 /app WORKDIR /app -CMD ["bin/fake-smtp", "--config", "fake-smtp.yml"] \ No newline at end of file +RUN mkdir -p /app + +CMD ["bin/fake-smtp", "--config", "config.yml"] \ No newline at end of file diff --git a/misc/docker/config-patch.yml b/misc/docker/config-patch.yml new file mode 100644 index 0000000..cf67519 --- /dev/null +++ b/misc/docker/config-patch.yml @@ -0,0 +1,4 @@ +--- +- op: replace + path: /smtp/debug + value: false \ No newline at end of file