#Not able to login with Docker Compose

11 messages · Page 1 of 1 (latest)

undone robin
#

I have tried to create a docker compose file for the Medusa Backend with the admin. I would like to run it locally via docker.

However, when I try to locally without docker, with the command: npm run start its able to run fine and I am able to login.

However, when I try to run it via docker compose, I am able to get to the login page, but even if the credentials are correct, it does not let me login. And seems to just refresh the login page. ( if creds are wrong, it mentions that they are wrong in the error message, but nothing if they are fine )

I am dont know what I am doing wrong here. Can anyone please advise? Was anyone able to get the latest medusa started with docker compose?

Here is my docker-compose.yml file :

version: "3.8"
services:
  backend:
    build:
      dockerfile: Dockerfile
    image: backend:latest
    container_name: medusa-server
    restart: always
    command: ["npm", "run", "start"]
    depends_on:
      - postgres
      - redis
    environment:
      DATABASE_URL: postgres://postgres:postgres@postgres:5432/medusa-docker
      REDIS_URL: redis://redis:6379
      NODE_ENV: production
      # STORE_CORS: http://localhost
      JWT_SECRET: something
      COOKIE_SECRET: something

    volumes:
      - medusa-data:/data
    ports:
      - "9000:9000"

  postgres:
    image: postgres:10.4
    ports:
      - "5432:5432"
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: medusa-docker

  redis:
    image: redis
    container_name: cache
    volumes:
      - cache-data:/data
    expose:
      - 6379

volumes:
  medusa-data:
  db-data:
  cache-data:

Here is my Dockerfile:

FROM node:18-alpine

WORKDIR /app/medusa

RUN npm install -g @medusajs/medusa-cli cross-env
COPY package*.json ./
RUN npm install

COPY . .
#

These are the scripts in my package.json:

"scripts": {
    "clean": "cross-env ./node_modules/.bin/rimraf dist",
    "build": "cross-env npm run clean && npm run build:server && npm run build:admin",
    "build:server": "cross-env npm run clean && tsc -p tsconfig.server.json",
    "build:admin": "cross-env medusa-admin build --deployment",
    "watch": "cross-env tsc --watch",
    "test": "cross-env jest",
    "seed": "cross-env medusa seed -f ./data/seed.json",
    "start": "medusa migrations run && medusa start",
    "start:custom": "cross-env npm run build && node --preserve-symlinks --trace-warnings index.js",
    "dev": "cross-env npm run build:server && medusa develop"
  },

Any help would be appreciated.

vernal burrow
#

Possible cors error.

#

Try to build and start with np2

undone robin
#

What is np2?

#

It might be a cors issue, but the console should have warned me if it was. However, all I am getting is unathorized.

#

When I try Curling the request for auth, its working :

undone robin
#

Ok I think I figured it out. Seems like the NODE_ENV: production is not needed and when I add it, it does not login.

near sable
#

@undone robin

#

is this dockerfile working

fervent sparrow
#

I had this problem, I fixed it using https