Open mitul-srashtasoft opened 2 years ago
I have the same error , how can we solve it? Thanks!!
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
Hmmm, there are actually quite a few other issues. 😓
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
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?
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.
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 medusa@docker.local
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
ADMIN_LOGIN_EMAIL=you@yours.com
ADMIN_LOGIN_PASSWORD=your-strong-admin-password
NODE_OPTIONS=--openssl-legacy-provider
Package.json is not found in backend:test