瀏覽代碼

update docker compose setup

Philip Korsholm 3 年之前
父節點
當前提交
c0a0393e28
共有 4 個文件被更改,包括 18 次插入6 次删除
  1. 4 2
      Dockerfile
  2. 10 1
      README.md
  3. 0 3
      develop.sh
  4. 4 0
      docker-compose.yml

+ 4 - 2
Dockerfile

@@ -2,7 +2,9 @@ FROM node:17.1.0
 
 WORKDIR /app/medusa
 
-COPY package.json .
+COPY . .
+
+RUN rm -rf node_modules
 
 RUN apt-get update
 
@@ -12,6 +14,6 @@ RUN npm install -g npm@latest
 
 RUN npm install -g @medusajs/medusa-cli
 
-COPY . .
+RUN npm install
 
 ENTRYPOINT ["./develop.sh"]

+ 10 - 1
README.md

@@ -51,7 +51,7 @@ This starter has minimal prerequisites and most of these will usually already be
 
 Your local Medusa server is now running on port **9000**.
 
-## Setting up your store with docker
+## Setting up your store with docker and postgres
 
 - Create a new Medusa project
   ```
@@ -76,6 +76,15 @@ Your local Medusa server is now running on port **9000**.
   ```
 
 - Run your project
+
+  When running your project the first time `docker compose` should be run with the `build` flag to build your contianer locally:
+
+  ```
+  docker compose up --build
+  ```
+
+  When running your project subsequent times you can run docker compose with no flags to spin up your local environment in seconds:
+
   ```
   docker compose up
   ```

+ 0 - 3
develop.sh

@@ -1,8 +1,5 @@
 #!/bin/bash
 
-#Install packages
-npm install --loglevel=error
-
 #Run migrations to ensure the database is updated
 medusa migrations run
 

+ 4 - 0
docker-compose.yml

@@ -18,6 +18,7 @@ services:
       - "9000:9000"
     volumes:
       - .:/app/medusa
+      - node_modules:/app/medusa/node_modules
 
   postgres:
     image: postgres:10.4
@@ -33,3 +34,6 @@ services:
     container_name: medusa-cache
     expose:
       - 6379
+
+volumes:
+  node_modules: