Skip to content

Commit

Permalink
feat: Support running malibu in docker (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
gja authored Mar 13, 2019
1 parent 7ec8778 commit 6ae0159
Show file tree
Hide file tree
Showing 8 changed files with 8,421 additions and 11,823 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ $ git pull [email protected]:quintype/malibu.git master
$ git checkout --ours app/isomorphic/components
$ git add app/isomorphic/components
```

## Running on Windows

Here are some considerations while running on windows
* Please install docker (Docker for Desktop on Windows Enterprise / Professional, and Docker Toolbox on Windows Home)
* The app is to be run as follows: `./dev-docker/start`
* In case localhost:3000 shows a connection refused, you can forward ports to the `docker-machine` as follows `./dev-docker/port-forward`. This should only be needed on Windows home
* Windows uses nodemon and webpack polling to detect updates. This eats CPU
* You can use `./dev-docker/force-reload` to force the web server and webpack to reload
15 changes: 15 additions & 0 deletions dev-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:10.15-alpine

RUN apk update && \
apk add bash tini && \
addgroup -S app && \
adduser -S -g app app

RUN mkdir -p /app/node_modules && chown app:app -R /app
VOLUME ["/app", "/app/node_modules"]

WORKDIR /app
USER app

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["bash"]
3 changes: 3 additions & 0 deletions dev-docker/force-reload
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker-compose exec web touch app/isomorphic/app-version.js
3 changes: 3 additions & 0 deletions dev-docker/port-forward
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker-machine ssh default -fN -L 3000:localhost:3000 -L 8080:localhost:8080
18 changes: 18 additions & 0 deletions dev-docker/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

export NODEMON_OPTS=""
export WEBPACK_DEV_OPTS=""

if [[ "$(pwd)" != "$HOME"* ]]; then
echo This script must be run in a codebase located within the $HOME folder. Please re-clone this repository and try again
exit 1
fi

if [ "$MSYSTEM" == "MINGW64" ]; then
export NODEMON_OPTS="$NODEMON_OPTS --polling-interval 200"
export WEBPACK_DEV_OPTS="$WEBPACK_DEV_OPTS --watch-poll"
fi

docker-compose build &&\
docker-compose run web npm install &&\
docker-compose up
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
web: &common
build: ./dev-docker
volumes:
- .:/app
- node_modules:/app/node_modules
dns:
- 8.8.8.8
- 1.1.1.1
ports: ["3000:3000"]
command: sh -c 'npm run compile && npm run dev-server -- ${NODEMON_OPTS}'
assets:
<<: *common
ports: ["8080:8080"]
command: npm run asset-server -- --host 0.0.0.0 ${WEBPACK_DEV_OPTS}
volumes:
node_modules:
Loading

0 comments on commit 6ae0159

Please sign in to comment.