Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest versions of mailhog and mongodb incompatible (docker-compose) #427

Open
ghost opened this issue Dec 8, 2022 · 3 comments
Open

Latest versions of mailhog and mongodb incompatible (docker-compose) #427

ghost opened this issue Dec 8, 2022 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 8, 2022

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"
@superbiche
Copy link

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

@mipmip
Copy link

mipmip commented Aug 29, 2023

See mailhog/storage#12
You can compile a working version with: https://github.com/vmary2014/MailHog

@p1ratrulezzz
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants