Last active
March 20, 2024 05:23
-
-
Save oxechicao/446c215e2b50b80391dd6427a328c25e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
db: | |
image: mysql:latest | |
environment: | |
- MYSQL_ROOT_PASSWORD=rootinha | |
- MYSQL_DATABASE=dbzin | |
ports: | |
- "3306:3306" | |
app: | |
build: . | |
ports: | |
- "8080:8080" | |
depends_on: | |
- db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:latest | |
WORKDIR /usr/src/app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
EXPOSE 8080 | |
CMD node index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mysql = require('mysql2') | |
const connection = mysql.createConnection({ | |
host : 'db', | |
port: '3306', | |
user : 'root', | |
password : 'rootinha', | |
database : 'dbzin' | |
}); | |
connection.connect((error) => { | |
if (error) { | |
console.error('Error connecting to MySQL database:', error); | |
} else { | |
console.log('Connected to MySQL database!'); | |
} | |
}); | |
// close the MySQL connection | |
// | |
connection.end() | |
console.log("NICE!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "ntd", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"mysql2": "^3.9.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment