here is my db.js file
let connection = mysql.createConnection({
host: process.env.DATABASE_HOST || '127.0.0.1',
user: 'root',
database: 'bc2k19',
password: 'joeydash',
port: 33060
});
here is my docker-compose.yml file
version: '3.2'
services:
app:
build: ./app
ports:
- "3000:3000"
depends_on:
- db
environment:
- DATABASE_HOST=db
db:
build: ./db
ports:
- "3306:3306"
here is my dockerfile for mysql
FROM mysql:latest
ENV MYSQL_ROOT_PASSWORD joeydash
ENV MYSQL_DATABASE bc2k19
ENV MYSQL_USER joeydash
ENV MYSQL_PASSWORD joeydash
ADD setup.sql /docker-entrypoint-initdb.d
here is my dockerfile for my app
# Use Node v4 as the base
image.
FROM node:latest
# Add everything in the current directory to our image, in the 'app' folder.
ADD . /app
# Install dependencies
RUN cd /app; \
npm install --production
# Expose our server port.
EXPOSE 3000
# Run our app.
CMD ["node", "/app/bin/www"]
I don't know why everytime I try to do docker-compose up and connect it shows
Error: connect ECONNREFUSED 127.0.0.1:3306
app_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)
It shoes like the connection is not set but it is set