Latest versions of mailhog and mongodb incompatible (docker-compose)
barezina-intellipharm opened this issue · comments
Bob Arezina commented
Replicate using this docker-compose.yml:
version: "3.9"
services:
mailhog:
image: "mailhog/mailhog:latest"
ports:
- "50001:8025"
- "50002:1025"
environment:
MH_STORAGE: mongodb
MH_MONGO_URI: "mongo:27017"
depends_on:
- mongo
mongo:
image: "mongo:latest"
Michel Tomas commented
I went back to Mongo 4.20 to make it work.
If you need a more recent Mongo, just add a second mail_mongo
service with version 4.20 or so
Pim Snel commented
See mailhog/storage#12
You can compile a working version with: https://github.com/vmary2014/MailHog
P1ratRuleZZZ commented
Thanks to comment #1697868253
I was able to build a new version with a working storage and also I had to fix sort order for mongodb to descending, that's why I'm using my own fork for storage.
Urls like mongodb://127.0.0.1:27017 now working!
Here is a dockerfile, maybe it will help someone
#
# MailHog Dockerfile
#
FROM golang:alpine as builder
ARG VERSION=master
ARG STORAGE_VERSION="v1.1.1"
# Install MailHog:
RUN apk --no-cache add --virtual build-dependencies gcc musl-dev make git
RUN mkdir -p /root/gocode && export GOPATH=/root/gocode && go install github.com/mitchellh/gox@latest
RUN git clone --branch ${VERSION} https://github.com/mailhog/MailHog
RUN cd MailHog \
&& go mod init \
&& go mod tidy \
&& go mod vendor \
&& go mod edit -replace github.com/mailhog/storage=github.com/p1ratrulezzz/mailhog-storage@${STORAGE_VERSION} \
&& go mod tidy \
&& go mod vendor
RUN export GOPATH=/root/gocode && export PATH=$PATH:$GOPATH/bin && cd MailHog && gox -osarch="linux/amd64" -ldflags "-X main.version=${VERSION}" -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}"
FROM alpine:3
# Add mailhog user/group with uid/gid 1000.
# This is a workaround for boot2docker issue #581, see
# https://github.com/boot2docker/boot2docker/issues/581
RUN adduser -D -u 1000 mailhog
COPY --from=builder /go/MailHog/build/MailHog_linux_amd64 /usr/local/bin/MailHog
USER mailhog
WORKDIR /home/mailhog
ENTRYPOINT ["MailHog"]
# Expose the SMTP and HTTP ports:
EXPOSE 1025 8025