Skip to content

Instantly share code, notes, and snippets.

@ChristianRich
Last active January 30, 2017 04:22
Show Gist options
  • Save ChristianRich/0f423175dd0b02a2605047ed80b6dcb1 to your computer and use it in GitHub Desktop.
Save ChristianRich/0f423175dd0b02a2605047ed80b6dcb1 to your computer and use it in GitHub Desktop.
version: "2"
services:
nginx:
restart: always
build: ./nginx
ports:
- "8080:80"
volumes:
- /www/public
volumes_from:
- web
links:
- web:web
web:
build:
context: .
dockerfile: ./app/DockerFile
depends_on:
- mongo
volumes:
- ./:/app
ports:
- "32768:3000"
environment:
NODE_ENV: development
PORT: 3000
links:
- mongo
mongo:
image: mongo:latest
command: mongod --smallfiles --dbpath /data/db --nojournal --oplogSize 16 --noauth
ports:
- "27017:27017"
volumes_from:
- mongodata
mongodata:
image: tianon/true
volumes:
- /data/db
FROM nginx
# File Author / Maintainer
MAINTAINER Christian Rich
# Copy custom configuration file from the current directory
COPY nginx.conf /etc/nginx/nginx.conf
FROM node:6.9.4
# Updates
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev libkrb5-dev
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN rm /etc/localtime && \
ln -s /usr/share/zoneinfo/Australia/Sydney/etc/localtime
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 3000
CMD [ "npm", "start" ]
worker_processes 4;
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 50M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
upstream node-app {
least_conn;
server web:8080 weight=10 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
listen [::]:80;
server_name example.org;
charset utf-8;
location /public {
alias /src/app/build;
}
location / {
proxy_pass http://web:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment