Skip to content

Commit

Permalink
Merge pull request #53 from philtrep/yarn
Browse files Browse the repository at this point in the history
Added Yarn support for node
  • Loading branch information
philtrep authored Oct 18, 2016
2 parents 5327288 + a320d37 commit 7938b22
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Docker Compose for Node projects with Node, MySQL, MongoDB, NGINX, Certbot and R
- [Non-web project](#Non-Web)
- [Multiple Node containers](#Multi-Node)
- [More options](#More-Options)
- [Use Yarn](#Use-Yarn)
- [Change Node entrypoint](#Node-Entrypoint)
- [Change Node environment](#Node-Environment)
- [Change Node version](#Node-Version)
Expand Down Expand Up @@ -192,6 +193,17 @@ To customize the NoDock installation, either add a `docker-compose.override.yml`
```bash
docker-compose -f nodock/docker-compose.yml -f docker-compose.dev.yml up -d
```
<a name="Use-Yarn"></a>
#### Use Yarn
Set the `YARN` argument to `true`.
```yaml
# docker-compose.override.yml
[...]
node:
build:
args:
- YARN=true
```
<a name="Node-Entrypoint"></a>
#### Change the node entrypoint
Use `main.js` instead of `index.js`
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- NODE_VERSION=latest
- PROJECT_PATH=/opt/app/
- NODE_ENV=production
- YARN=false
volumes:
- ../:/opt/app
extra_hosts:
Expand Down
8 changes: 8 additions & 0 deletions node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ RUN apt-get update &&\
ARG NODE_ENV
ARG NODE_VERSION
ARG PROJECT_PATH
ARG YARN

ENV YARN=$YARN
ENV PROJECT_PATH=$PROJECT_PATH
ENV NODE_ENV=$NODE_ENV

Expand All @@ -18,6 +20,12 @@ RUN groupadd -r www-app &&\
# Install the specified NODE_VERSION or grab latest
RUN n "$NODE_VERSION"

# Install Yarn

RUN if [ ${YARN} = true ]; then \
npm install -g yarn \
;fi

COPY scripts/run-nodock.sh /usr/bin/run-nodock

RUN chmod 700 /usr/bin/run-nodock
Expand Down
6 changes: 5 additions & 1 deletion node/scripts/run-nodock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ fi

cd $PROJECT_PATH

npm install
if [[ $YARN = true ]]; then
yarn install
else
npm install
fi

su -c "cd $PROJECT_PATH; $SCRIPT" -s /bin/bash www-app
3 changes: 3 additions & 0 deletions workspace/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ ARG NODE_VERSION
# Install the specified NODE_VERSION or grab latest
RUN n "$NODE_VERSION"

# Install YARN
RUN npm i -g yarn

##
## Cron
##
Expand Down

0 comments on commit 7938b22

Please sign in to comment.