Skip to content

Adds Docker compose for app and MySQL 8.0 #12

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

Merged
merged 1 commit into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const config = {
user: env.DB_USER || '2ZE90yGC6G',
password: env.DB_PASSWORD || 'JZFqXibSmX',
database: env.DB_NAME || '2ZE90yGC6G',
port: env.DB_PORT || '3306',
waitForConnections: true,
connectionLimit: env.DB_CONN_LIMIT || 2,
queueLimit: 0,
Expand Down
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.8'
services:
db:
image: mysql:8.0
cap_add:
- SYS_NICE
restart: always
environment:
- MYSQL_DATABASE=quotes
- MYSQL_ROOT_PASSWORD=mauFJcuf5dhRMQrjj
ports:
- '3306:3306'
volumes:
- db:/var/lib/mysql
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
api:
container_name: quotes-api
build:
context: ./
target: production
image: quotes-api
depends_on:
- db
ports:
- 3000:3000
environment:
NODE_ENV: production
DB_HOST: db
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: mauFJcuf5dhRMQrjj
DB_NAME: quotes
links:
- db
volumes:
- ./:/src
volumes:
db:
driver: local
2 changes: 1 addition & 1 deletion services/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function getMultiple(page = 1){
const offset = helper.getOffset(page, config.listPerPage);
const rows = await db.query(
'SELECT id, quote, author FROM quote LIMIT ?,?',
[offset, config.listPerPage]
[offset.toString(), config.listPerPage.toString()]
);
const data = helper.emptyOrRows(rows);
const meta = {page};
Expand Down