I’m running in a docker container called nuxtsrapi
with two apps as two different images. one is a nuxt3 app in a folder named frontend
on port 3000 the other is a strapi4 app in a backend
on port 1337.
my strapi app is set up for sqlite as db and I’m using yarn.
My questions are:
- How can I be able to connect them so that when I run the container I won’t get the error:
nuxtstrapi-frontend-1 | Error: connect ECONNREFUSED 127.0.0.1:1337
- How should set up my files do they will run a develop env on my local machine and production on a server
Here are some content of my docker files
Dockerfile in frontend
FROM node:14.19.1
WORKDIR /app/frontend
COPY package*.json ./
RUN yarn install
COPY . .
EXPOSE 3000
CMD ["yarn", "dev"]
Dockerfile in backend
FROM node:14.19.1
WORKDIR /app/backend
COPY package*.json ./
RUN yarn install
COPY . .
EXPOSE 1337
CMD ["yarn", "start"]
docker-compose.yml in root
version: '3'
services:
frontend:
build:
context: ./frontend
ports:
- 3000:3000
backend:
build:
context: ./backend
ports:
- 1337:1337
environment:
DATABASE_CLIENT: sqlite
DATABASE_NAME: strapi
DATABASE_HOST: backend
DATABASE_PORT: 1337
DATABASE_USERNAME: strapi
DATABASE_PASSWORD: strapi