Docker configuration

docker
sundowndev 2018-09-03 17:53:26 +02:00
parent 4b04c4690f
commit 7bff3dcb0d
7 changed files with 115 additions and 30 deletions

11
.dockerignore Normal file
View File

@ -0,0 +1,11 @@
**/*.log
**/._*
**/.DS_Store
**/.gitignore
**/.gitattributes
**/Thumbs.db
.dockerignore
Dockerfile
docker-compose.yaml
/node_modules/
/npm-debug.log/

View File

@ -0,0 +1,33 @@
# Set the base image to Ubuntu
FROM ubuntu:14.04
MAINTAINER Adrien Desbiaux
# Install Node.js and other dependencies
RUN apt-get update && \
apt-get -y install curl && \
apt-get -y install git && \
apt-get -y install wget && \
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - && \
apt-get install --yes nodejs
# Install PM2
RUN npm install -g pm2
RUN mkdir -p /var/www/app
# Define working directory
WORKDIR /var/www/app
ADD . /var/www/app
RUN npm install
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker/nginx/docker-entrypoint.sh"]
# Expose port
EXPOSE 3000
# Run app
CMD pm2 start --no-daemon processes.json

View File

@ -1,30 +1,18 @@
version: '3'
services:
app:
build:
context: .
dockerfile: ./Dockerfile
nginx:
build:
context: .
dockerfile: ./Dockerfile.nginx
depends_on:
- app
volumes:
# Comment out the next line in production
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
- ./dist:/srv/app:ro
ports:
- '3000:80'
# This HTTP/2 proxy is not secure: it should only be used in dev
h2-proxy:
build:
context: .
dockerfile: ./Dockerfile.h2-proxy
volumes:
- ./docker/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro
ports:
- '443:443'
nginx:
build: ./docker/nginx
links:
- app1:app1
ports:
- "8000:80"
- "443:443"
volumes:
- /etc/nginx/psw:/etc/nginx/psw
- /etc/nginx/ssl:/etc/nginx/ssl
app1:
build: .
ports:
- "3000"
volumes:
- /tmp:/tmp
environment:
- MODE=dev

23
docker/nginx/Dockerfile Normal file
View File

@ -0,0 +1,23 @@
# Set nginx base image
FROM nginx
# File Author / Maintainer
MAINTAINER Adrien Desbiaux
COPY docker-entrypoint.sh /
ENTRYPOINT ["./docker-entrypoint.sh"]
# Copy custom configuration file from the current directory
COPY nginx.conf /etc/nginx/nginx.conf
VOLUME ["/etc/nginx/ssl", "/etc/nginx/psw"]
# Append "daemon off;" to the beginning of the configuration
# in order to avoid an exit of the container
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# Expose ports
EXPOSE 443
# Define default command
CMD service nginx start

View File

@ -0,0 +1,4 @@
#!/bin/bash -e
sed -i s/localhost/localhost/g /etc/nginx/nginx.conf
cat /etc/nginx/nginx.conf
exec "$@"

View File

@ -0,0 +1,17 @@
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
access_log /var/log/nginx/nodejs_project.log;
charset utf-8;
location /public {
alias /src/app/public;
}
location / {
proxy_pass http://server: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;
}
}

9
processes.json Normal file
View File

@ -0,0 +1,9 @@
{
"apps" : [{
"merge_logs" : true,
"name" : "worker1",
"out_file" : "/tmp/workers.log",
"log_date_format" : "MM/DD/YYYY HH:mm:ss",
"script" : "lib/worker.js"
}]
}