-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Docker strapi error #130
Comments
This would be because you need to connect to 0.0.0.0:5432 because localhost is for the container itself also the container might need to be exposed if it's docker compose. |
@Eventyret To resolve this, I tried adjusting the host and port settings as per the Vite server-options, but the error message remains the same in the console. // src/admin/vite.configs.ts
import { mergeConfig, type UserConfig } from 'vite';
import dns from 'node:dns'
dns.setDefaultResultOrder('verbatim');
export default (config: UserConfig) => {
// Important: always return the modified config
return mergeConfig(config, {
resolve: {
alias: {
'@': '/src',
},
},
server: {
// https: false,
host: 'localhost',
cors: {
origin: ['http://localhost:3000'],
credentials: true,
},
},
optimizeDoptimizeDeps: {
exclude: ['node_modules/.cache'],
},
})
} version: '3'
services:
web-api:
container_name: web-api
build: .
image: web-api:latest
restart: unless-stopped
env_file: .env
environment:
DATABASE_CLIENT: ${DATABASE_CLIENT}
DATABASE_HOST: web-api-DB
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USERNAME: ${DATABASE_USERNAME}
DATABASE_PORT: ${DATABASE_PORT}
JWT_SECRET: ${JWT_SECRET}
ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
NODE_ENV: ${NODE_ENV}
volumes:
- ./config:/opt/app/config
- ./src:/opt/app/src
- ./package.json:/opt/package.json
- ./yarn.lock:/opt/yarn.lock
- ./.env:/opt/app/.env
- ./public/uploads:/opt/app/public/uploads
ports:
- '1337:1337'
- '5173:5173' # Vite 포트 노출
networks:
- web-api
depends_on:
- web-api-DB
web-api-DB:
container_name: web-api-DB
platform: linux/amd64 #for platform error on Apple M1 chips
restart: unless-stopped
env_file: .env
image: postgres:14.5-alpine
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- web-api-data:/var/lib/postgresql/data/ #using a volume
#- ./data:/var/lib/postgresql/data/ # if you want to use a bind folder
ports:
- '15432:5432'
networks:
- web-api
web-api-Adminer:
container_name: web-api-Adminer
image: adminer
restart: unless-stopped
ports:
- '9090:8080'
environment:
- ADMINER_DEFAULT_SERVER=web-api-DB
networks:
- web-api
depends_on:
- web-api-DB
volumes:
web-api-data:
networks:
web-api:
name: web-api
driver: bridge |
Would have to set the network to host and 0.0.0.0 if your using it not in a docker network as per docker documentation |
@Eventyret I don't know what you mean.
|
🐛 Bug Report
🤷♀️ What did you do
I don't know the details, but it seems that vite can't connect to port 5173, so I can't access the admin page. I keep refreshing it, and it works.
This problem only occurs when running with Docker.
If you set only DB and Adminer in docker-compose, and run strapi with
yarn develop
in the root directory, the problem doesn't occur.⛔️ Error log
The text was updated successfully, but these errors were encountered: