Skip to content

Docker #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official Node 8 runtime as a parent image
FROM node:boron

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install node dependencies
RUN npm install

# Run node app when the container launches
CMD ["node", "."]

# Make port 3000 available to the world outside this container
EXPOSE 3000
2 changes: 2 additions & 0 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.0'
services:
app:
# If a context is not provided Docker looks for a file named "Dockerfile"
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- .:/app
nginx:
build:
context: .
dockerfile: Dockerfile.nginx
ports:
- 8080:8080
depends_on:
- app
38 changes: 38 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {

upstream node_app {
# By default docker-compose sets up a single network for your app.
# Each container for a service joins the default network and is both reachable by other containers on that network,
# and discoverable by them at a hostname identical to the container name.
# https://docs.docker.com/compose/networking/
server app:3000;
}

server_tokens off;

# Define the MIME types for files.
include mime.types;
default_type application/octet-stream;

# Speed up file transfers by using sendfile()
sendfile on;

server {
listen 8080;
server_name localhost;

location / {
proxy_pass http://node_app;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}