Skip to content

Commit

Permalink
Merge pull request #15 from endorphin82/dev
Browse files Browse the repository at this point in the history
process dockerize
  • Loading branch information
stdihdev committed Oct 7, 2020
2 parents 6596b87 + bb3e09d commit e0e69ac
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules
node_modules
.env
*.env
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:12

# Setting working directory. All the path will be relative to WORKDIR
# cd /usr/src/app
WORKDIR /usr/src/app

# Installing dependencies
COPY package*.json ./
RUN npm install

# Copying source files
COPY . .

# Building app
RUN npm run build

# Running the app
CMD [ "npm", "run", "migration" ]
CMD [ "npm", "run", "start" ]
4 changes: 2 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME,
host: process.env.DATABASE_HOST,
port: process.env.DATABASE_PORT,
dialect: process.env.DATABASE_DIALECT
port: "",
dialect: 'mysql'
}
}
46 changes: 46 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: "3.3"

volumes:
mysql_volume:

services:
mysql:
image: library/mysql:8.0.21
restart: always
environment:
MYSQL_DATABASE: 'nextjs-shop'
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_USER: 'root'
MYSQL_ROOT_HOST: 0.0.0.0
MYSQL_PASSWORD: root
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- mysql_volume:/var/lib/mysql
networks:
- web_service
web_service:
build:
context: .
dockerfile: ./Dockerfile
restart: always
ports:
- 3000:3000
networks:
- web_service
environment:
- PORT=3000
- MYSQL_ADDR=mysql
- API_URL="http://localhost/api/graphql"
- DATABASE_URL="mysql://root:root@localhost/nextjs-shop"
- DATABASE_USER="root"
- DATABASE_PASSWORD="root"
- DATABASE_NAME="nextjs-shop"
- DATABASE_HOST="0.0.0.0"
- DATABASE_PORT=3306
- DATABASE_DIALECT="mysql"
networks:
web_service:
driver: bridge
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"migration:create:db": "sequelize db:create",
"migration:up": "npx sequelize-cli db:migrate up",
"generateHoocs": "graphql-codegen",
"docker-compose:up": "docker-compose up",
"clearHoocs": "find ./components -name \"__generated__\" -exec rm -rf '{}' +",
"prettier:check": "prettier --ignore-path .eslintignore --check \"**/*.{css,html,js,jsx,md,yaml,ts,tsx}\""
},
Expand Down

0 comments on commit e0e69ac

Please sign in to comment.