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

Package.json is not found in backend:test #2

Open
mitul-srashtasoft opened this issue Jan 13, 2022 · 7 comments
Open

Package.json is not found in backend:test #2

mitul-srashtasoft opened this issue Jan 13, 2022 · 7 comments

Comments

@mitul-srashtasoft
Copy link

Package.json is not found in backend:test

@carbans
Copy link

carbans commented Jan 18, 2022

I have the same error , how can we solve it?
Thanks!!

@rsaffi
Copy link

rsaffi commented Jan 18, 2022

For now, to bypass this I've gone ahead and grabbed the package.json from the medusajs/medusa repository and put it into the backend folder, and re-run docker-compose up --build, which did the trick.

From the root of this medusajs/docker-medusa repo:

wget "https://raw.githubusercontent.com/medusajs/medusa/master/package.json" -O backend/package.json
sed -i 's,=error,=error --force,' backend/Dockerfile
docker-compose up --build
docker-compose up -d

@rsaffi
Copy link

rsaffi commented Jan 18, 2022

Hmmm, there are actually quite a few other issues. 😓

@YeonV
Copy link

YeonV commented Jan 27, 2022

First of all, thanks for this amazing project!!

Would be AWESOME if there would be a working docker-compose example <3

Also can we change the postgres port used by this stack by just adding command -p to postgres and changing the database url accordingly?

Thanks in advance

@Themis3000
Copy link

Hmmm, there are actually quite a few other issues. 😓

I'm trying to decide if it's worth it to try and figure this all out and get this running through docker compose or if I should cut my losses and ditch using docker or create my own docker compose file from scratch. Did you ever get it working using docker compose? What where the other issues?

@Themis3000
Copy link

I talked with a maintainer on discord and they said that you're supposed to bootstrap a medusa project using npx create-medusa-app, then merge the files of this repo into your project, then it should all work. I haven't given it a test yet, I'll update if I do test this out and remember to.

@elhardoum
Copy link

That's not all. This repository is not ready for use because it lacks some documentation. When they throw in a COPY . . step where we do not have a package.json or any app/boilerplate code then I am sure it won't work. You should follow the official docs on how to create a new project and use that in your docker setup.

Anyhow, this is what worked for me (still struggling with building the last missing piece, the storefront) - note: I used api instead of backend for folder naming:

# api/Dockerfile
FROM node:17.0.0-alpine

WORKDIR /usr/src/app

RUN apk update && apk add git

RUN git config --global user.name medusa-user
RUN git config --global user.email [email protected]

RUN npm install -g @medusajs/medusa-cli

RUN test -f develop.sh || medusa new . --seed

# enable if you have a config file
# COPY api/medusa-config.js .

COPY api/entrypoint.sh .

ENTRYPOINT [ "sh", "entrypoint.sh" ]
# api/entrypoint.sh
#!/usr/bin/env sh

# run migrations
medusa migrations run

# create admin login
medusa user -e "$ADMIN_LOGIN_EMAIL" -p "$ADMIN_LOGIN_PASSWORD"

# run api server
medusa develop
# docker-compose.yml
version: '3'
services:
  # medusa store api
  api:
    image: medusa-api
    # volumes: # enable when you have a local config file
    #   - ./api/medusa-config.js:/usr/src/app/medusa-config.js
    working_dir: /usr/src/app
    ports:
      - 9000:9000
    depends_on:
      - pg
      - redis
    restart: always
    build:
      context: .
      dockerfile: api/Dockerfile
    env_file: .env
    environment:
      STORE_CORS: ${API_STORE_CORS}

  # database
  pg:
    image: postgres:11.2-alpine
    restart: always
    volumes:
      - ./data/pg:/var/lib/postgresql/data
    env_file: .env

  # cache
  redis:
    image: redis:3.2-alpine
    restart: always
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - ./data/redis:/data

volumes:
  data:
# .env
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=medusa
DATABASE_URL=postgres://postgres:postgres@pg:5432/medusa
REDIS_URL=redis://redis
NODE_ENV=dev
API_STORE_CORS=http://localhost
GATSBY_MEDUSA_BACKEND_URL=http://api:9000
GATSBY_STORE_URL=http://localhost:6000
[email protected]
ADMIN_LOGIN_PASSWORD=your-strong-admin-password
NODE_OPTIONS=--openssl-legacy-provider

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

6 participants