Issue setting up MailGun adapter

I’ve got an instance of Parse-Server setup using Docker. Everything is working fine except for the module @parse/simple-mailgun-adapter.

I have installed @parse/simple-mailgun-adapter using:

npm install --save @parse/simple-mailgun-adapter

This looks to be correctly installed as it’s added to package.json and doesn’t throw errors upon installation.

I use Portainer to manage my docker containers and manage ENV Variables from there. I have added a variable

PARSE_SERVER_EMAIL_ADAPTER

with the value set as

{ module: "@parse/simple-mailgun-adapter", options: { fromAddress: "[email protected]", domain: "xxx", apiKey: "xxx", } }

But when I redeploy my container, I simple get

`internal/modules/cjs/loader.js:638

throw err;
^

Error: Cannot find module '{ module: “@parse/simple-mailgun-adapter”`

I’m fairly new to NPM/Docker, any suggestions?

Can you share the step-by-step of all commands you used to setup the docker container? I understand that you have cloned the parse-server repository, are using the Dockerfile of this clone and the module is in the package.json of the clone. Right? Have you rebuilt the image after installing the module?

Thanks for your help!

Inside my docker container, I’m installing simple-mailgun-adapter

Then I can see that added in my package.json (If this means it’s installed correctly)

Then I add it to my environment variables via Portainer.

Then I deploy it again and I get this error.

Again, I’m not an expert in the Docker area, or with NPM etc

Appreciate the help!

I’m afraid you will not be able to set the email adapter through env var since you need to send an object. You will need to create a config.json file with all your settings and initialize parse-server with this. I am not familiar with Portainer, but here are the steps I did in my local machine and worked for me:
config.json

{
  "appId": "APPLICATION_ID",
  "masterKey": "MASTER_KEY",
  "databaseURI": "mongodb://mongo/test",
  "emailAdapter": {
    "module": "@parse/simple-mailgun-adapter",
    "options": {
      "fromAddress": "[email protected]",
      "domain": "yourdomain.com",
      "apiKey": "xxx"
    }
  }
}

Commands sequence:

$ git clone https://github.com/parse-community/parse-server
$ cd parse-server
$ npm install --save @parse/simple-mailgun-adapter
$ mkdir config
$ vi ./config/config.json # then paste the json content in this file and save it (:wq)
$ docker build --tag parse-server .
$ docker run --name my-mongo -d mongo
$ docker run --name my-parse-server --link my-mongo:mongo -v /absolute-path-to-your-folder/parse-server/config/:/parse-server/config/ -d parse-server -- /parse-server/config/config.json

Amazing, thank you for your help!

I have taken your advice and I now use a config.json rather than environment variables to define my Parse Server instance.

For anyone using Portainer (Or any other docker manager), simply add

-- /parse-server/config/config.json

to ‘Command’ and restart your service. If configured correctly, this should point to a volume so that updating/restart this instance should not affect it’s configuration.

Thanks for your help @davimacedo

1 Like