Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

How to make work "strapi develop --watch-admin"? #305

Open
aminta opened this issue Jun 28, 2021 · 3 comments
Open

How to make work "strapi develop --watch-admin"? #305

aminta opened this issue Jun 28, 2021 · 3 comments

Comments

@aminta
Copy link

aminta commented Jun 28, 2021

My composer file is:

version: '3'
services:
  strapi:
    image: strapi/strapi
    environment:
      DATABASE_CLIENT: postgres
      DATABASE_NAME: strapi
      DATABASE_HOST: postgres
      DATABASE_PORT: 5432
      DATABASE_USERNAME: strapi
      DATABASE_PASSWORD: strapi
    volumes:
      - ./app:/srv/app
    ports:
      - '1337:1337'
      - '8000:8000'
    depends_on:
      - postgres

  postgres:
    image: postgres
    environment:
      POSTGRES_DB: strapi
      POSTGRES_USER: strapi
      POSTGRES_PASSWORD: strapi
    volumes:
      - ./data:/var/lib/postgresql/data
    ports:
      - '5432:5432'  

When the server is started, in Docker attached shell I type: strapi develop --watch admin and I get:

debug ⛔️ Server wasn't able to start properly.
[2021-06-28T18:34:00.151Z] error The port 1337 is already used by another application.
root@af70eda90919:/srv/app# ℹ 「wds」: Project is running at http://localhost:8000/
ℹ 「wds」: webpack output is served from /admin/
ℹ 「wds」: Content not from webpack is served from /srv/app
ℹ 「wds」: 404s will fallback to /admin/
Starting the development server...

Admin development at http://0.0.0.0:8000/admin/

I can connect to http://0.0.0.0:8000/admin/ but when I log in with the correct password I get:

Failed to load resource: the server responded with a status of 400 (Bad Request)

and http://0.0.0.0:1337/admin/ is still up...

How can I first stop strapi develop and then launch strapi develop --watch admin?

@1019058432
Copy link

Hello, I also have such doubts. Is there a correct way to use it? Or who will resolve this doubt for me? thanks

@ChristianHeimke
Copy link

you have two different options:

option A

you just need to overwrite the docker command set in the Dockerfile of the strapi/strapi image in your compose file (L5):

version: '3'
services:
  strapi: 
    image: strapi/strapi
    command: strapi develop --watch admin
    environment:
      DATABASE_CLIENT: postgres
      DATABASE_NAME: strapi
      DATABASE_HOST: postgres
      DATABASE_PORT: 5432
      DATABASE_USERNAME: strapi
      DATABASE_PASSWORD: strapi
    volumes:
      - ./app:/srv/app
    ports:
      - '1337:1337'
      - '8000:8000'
    depends_on:
      - postgres

  postgres:
    image: postgres
    environment:
      POSTGRES_DB: strapi
      POSTGRES_USER: strapi
      POSTGRES_PASSWORD: strapi
    volumes:
      - ./data:/var/lib/postgresql/data
    ports:
      - '5432:5432'  

this should prevent the strapi develop command and use the strapi develop --watch admin.

option B

You can also overwrite the command during the start of docker-compose without changing the compose file:

docker-compose run strapi strapi develop --watch admin

(more detailed information can be found here: docker-compose run)

@bora89
Copy link

bora89 commented Apr 28, 2023

@ChristianHeimke it is not enough just to run with --watch admin, port 8000 should be exposed somehow and host should be probably 0.0.0.0 in config/admin.js, I have not figured it out myself

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants