Created
October 12, 2017 21:16
-
-
Save cpsubrian/5b4bff876bad6f8a245005562914c627 to your computer and use it in GitHub Desktop.
Docker Node App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add git-ignore syntax here of things you don't want copied into docker image | |
.git | |
.data | |
*Dockerfile* | |
*docker-compose* | |
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
volumes: | |
node_modules: | |
services: | |
# Node App Service | |
app: | |
build: | |
context: . | |
args: | |
- NODE_ENV=development | |
ports: | |
- '3000:3000' | |
volumes: | |
- .:/opt/app | |
- node_modules:/opt/app/node_modules | |
environment: | |
NODE_ENV: development | |
depends_on: | |
- redis | |
- mysql | |
- elasticsearch | |
- rabbitmq | |
command: bash | |
# Redis Service | |
redis: | |
image: redis:2.6.17 | |
ports: | |
- '6379' | |
# MySQL Service | |
mysql: | |
image: mysql:5.5.42 | |
ports: | |
- '3306' | |
environment: | |
MYSQL_ROOT_PASSWORD: secret | |
# Elasticsearch Service | |
elasticsearch: | |
image: elasticsearch:2.1.2 | |
ports: | |
- '9200' | |
- '9300' | |
# Rabbitmq Service | |
rabbitmq: | |
image: rabbitmq:3.5.3-management | |
ports: | |
- '5672' | |
- '15672' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu 12, Node 0.10.44 (same as aa server) | |
# @see https://hub.docker.com/r/nodesource/node/ | |
FROM nodesource/precise:0.10.44 | |
# Upgrade distro and install deps. | |
RUN apt-get update && apt-get install -y wget imagemagick | |
# Install 'dockerize'. | |
ENV DOCKERIZE_VERSION v0.5.0 | |
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | |
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | |
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | |
# Create directory for app. | |
RUN mkdir -p /opt/app | |
# Set our node environment. | |
ARG NODE_ENV=development | |
ENV NODE_ENV $NODE_ENV | |
# Default to port 3000 for node, and 5858 or 9229 for debug. | |
ARG PORT=3000 | |
ENV PORT $PORT | |
EXPOSE $PORT 5858 9229 | |
# Install dependencies first. | |
WORKDIR /opt/app | |
COPY package.json /opt/app | |
RUN npm install && npm cache clean --force | |
# Install joli. | |
RUN npm install -g joli | |
# Copy in our source code last, as it changes the most | |
WORKDIR /opt/app | |
COPY . /opt/app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment