Skip to content

Commit

Permalink
fixing docker for development & adding live reload
Browse files Browse the repository at this point in the history
  • Loading branch information
RmnRss committed Aug 14, 2020
1 parent beecfed commit 3f895b6
Show file tree
Hide file tree
Showing 9 changed files with 2,021 additions and 2,511 deletions.
20 changes: 18 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# node & npm
node_modules
npm-debug.log

# next
.next
.vscode
npm-debug.log

# docker
Dockerfile*
docker-compose*
.dockerignore

# git files
.git
.gitignore

# Generic files
README.md
LICENSE
.vscode
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM node:12
FROM node:12-alpine

# Create app directory
WORKDIR /usr/src/app

# Copy packages to the docker image
COPY package*.json ./
COPY package.json ./

# Installing dependencies
RUN npm install
Expand All @@ -13,10 +13,13 @@ RUN npm install
# RUN npm ci --only=production

# Copy the rest of the content
COPY . .
COPY . ./

# Opening port 3000
EXPOSE 3000:3000

# Starting server
CMD [ "npm", "run", "dev" ]
# Live reload
VOLUME [ "./:/src/app", "/app/node_modules", "/app/.next" ]

# Production
# VOLUME [ "./:/src/app"]
20 changes: 19 additions & 1 deletion api/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# node & npm
node_modules
npm-debug.log

# strapi
.cache
.tmp
build
exports
exports

# docker
Dockerfile*
docker-compose*
.dockerignore

# git files
.git
.gitignore

# Generic files
README.md
LICENSE
.vscode
12 changes: 5 additions & 7 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM strapi/base AS build
FROM strapi/base

# Create app directory
WORKDIR /usr/srv/app

# Copy packages to the docker image
COPY package*.json ./
COPY package.json ./

# Installing dependencies
RUN npm install
Expand All @@ -13,12 +13,10 @@ RUN npm install
# RUN npm ci --only=production

# Copy the rest of the content
COPY . .
COPY . ./

# Opening port 1337
EXPOSE 1337:1337

VOLUME [ "./:/srv/app" ]

# Starting server
CMD [ "npm", "run", "develop" ]
# Mounting volume to current directory
VOLUME [ "./:/srv/app" ]
17 changes: 17 additions & 0 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 20 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
version: "3.8"

services:
strapi:
build: ./api
container_name: strapi
image: strapi/base
working_dir: /srv/app
command: sh -c "npm install && npm run develop"
ports:
- "1337:1337"
volumes:
- ./api:/srv/app
restart: "on-failure"

next:
container_name: next
image: node:12-alpine
working_dir: /app
command: sh -c "npm install && npm run dev"
#environment:
#- NODE_ENV=production
ports:
- "3000:3000"
volumes:
- .:/app
# Live reload for modules
- /app/node_modules
# Live reload for next
- /app/.next
command: sh -c "npm install && npm run dev"
depends_on:
- strapi
restart: "on-failure"

strapi:
build: ./api
container_name: strapi
image: strapi/base
working_dir: /srv/app
ports:
- "1337:1337"
volumes:
- ./api:/srv/app
#environment:
#- NODE_ENV=production
command: sh -c "npm run develop"
5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ module.exports = {
],
});

config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
};

return config;
},
};
Loading

0 comments on commit 3f895b6

Please sign in to comment.