System Information
- Strapi Version: 4.0.7
- Host Operating System: Ubuntu 20.04
- Docker Image: node:16
- Database: postgres
- Image Node Version: 16
- Image NPM Version: 8.3.1
- Yarn Version: 1.22.17
Hi,
I created a strapi project using the CLI, directly from my host machine. After, I decided to dockerize my installation, so I created this docker-compose.yml
file
version: "3.9"
services:
db:
image: postgres
restart: always
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
volumes:
- ./postgres_data:/var/lib/postgresql/data
back:
build: ./back/
depends_on:
- db
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- HOST=${BACK_HOST}
- PORT=${BACK_PORT}
- APP_KEYS=${BACK_APP_KEYS}
- JWT_SECRET=${BACK_JWT_SECRET}
- API_TOKEN_SALT=${BACK_API_TOKEN_SALT}
ports:
- "${BACK_PORT}:${BACK_PORT}"
volumes:
- ./back:/usr/src/app/api
front:
build: ./front/
depends_on:
- db
environment:
API_URL: "http://back:${BACK_PORT:-1337}/api"
ports:
- "${FRONT_PORT:-3000}:3000"
volumes:
- ./front:/usr/src/app/front
Strapi is running on the back
container. As we can see, I added the same port on host and image, cause when I tried to only change the host machine port, strapi admin was making calls to the image port, and it blocked the whole page. My problem is, even with changing the port on env variable, image and host, strapi admin continue to call on port 1337. I removed the .env
because I exported all variables in the docker-compose file.
Here is my Dockerfile
:
FROM node:16
WORKDIR /usr/src/app/api
RUN yarn
CMD ["yarn", "develop"]
So my question is, why does Strapi Admin force the usage of 1337 port even if I change PORT
environment variable (and I can confirm the variable is detected, cause when strapi start, it gives me the good URL to access to admin, and if I try to access http://localhost:custom-port, the homepage load) ?
Hope someone will be able to help.
Thanks !