mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-04-10 00:53:51 +02:00
separate nginx and app in docker
This commit is contained in:
parent
c384cf9b56
commit
b3ae59f426
22
Dockerfile
22
Dockerfile
@ -1,18 +1,11 @@
|
|||||||
FROM ruby:2.3
|
FROM ruby:2.3
|
||||||
MAINTAINER peng@sleede.com
|
MAINTAINER peng@sleede.com
|
||||||
|
|
||||||
# cf: nginx Dockerfile : https://github.com/nginxinc/docker-nginx
|
|
||||||
RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
|
|
||||||
RUN echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list
|
|
||||||
|
|
||||||
ENV NGINX_VERSION 1.9.7-1~jessie
|
|
||||||
|
|
||||||
# Install apt based dependencies required to run Rails as
|
# Install apt based dependencies required to run Rails as
|
||||||
# well as RubyGems. As the Ruby image itself is based on a
|
# well as RubyGems. As the Ruby image itself is based on a
|
||||||
# Debian image, we use apt-get to install those.
|
# Debian image, we use apt-get to install those.
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
nginx=${NGINX_VERSION} \
|
|
||||||
nodejs \
|
nodejs \
|
||||||
supervisor
|
supervisor
|
||||||
|
|
||||||
@ -28,16 +21,6 @@ RUN bundle install --binstubs
|
|||||||
# Clean up APT when done.
|
# Clean up APT when done.
|
||||||
#RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
#RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
|
||||||
# Nginx
|
|
||||||
# Remove the default site
|
|
||||||
RUN rm /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
# forward request and error logs to docker log collector
|
|
||||||
RUN ln -sf /dev/stdout /var/log/nginx/access.log
|
|
||||||
RUN ln -sf /dev/stderr /var/log/nginx/error.log
|
|
||||||
|
|
||||||
|
|
||||||
# Web app
|
# Web app
|
||||||
RUN mkdir -p /usr/src/app
|
RUN mkdir -p /usr/src/app
|
||||||
RUN mkdir -p /usr/src/app/config
|
RUN mkdir -p /usr/src/app/config
|
||||||
@ -58,13 +41,14 @@ COPY . /usr/src/app
|
|||||||
# Volumes
|
# Volumes
|
||||||
VOLUME /usr/src/app/invoices
|
VOLUME /usr/src/app/invoices
|
||||||
VOLUME /usr/src/app/exports
|
VOLUME /usr/src/app/exports
|
||||||
|
VOLUME /usr/src/app/public
|
||||||
VOLUME /usr/src/app/public/uploads
|
VOLUME /usr/src/app/public/uploads
|
||||||
VOLUME /usr/src/app/public/assets
|
VOLUME /usr/src/app/public/assets
|
||||||
VOLUME /var/log/supervisor
|
VOLUME /var/log/supervisor
|
||||||
|
|
||||||
# Expose port 80 and ssl 443 to the Docker host, so we can access it
|
# Expose port 3000 to the Docker host, so we can access it
|
||||||
# from the outside.
|
# from the outside.
|
||||||
EXPOSE 80 443
|
EXPOSE 3000
|
||||||
|
|
||||||
# The main command to run when the container starts. Also
|
# The main command to run when the container starts. Also
|
||||||
# tell the Rails dev server to bind to all interfaces by
|
# tell the Rails dev server to bind to all interfaces by
|
||||||
|
@ -236,23 +236,30 @@ docker run --rm \
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run --restart=always -d --name=fabmanager \
|
docker run --restart=always -d --name=fabmanager \
|
||||||
-p 80:80 \
|
|
||||||
-p 443:443 \
|
|
||||||
--link=fabmanager-postgres:postgres \
|
--link=fabmanager-postgres:postgres \
|
||||||
--link=fabmanager-redis:redis \
|
--link=fabmanager-redis:redis \
|
||||||
--link=fabmanager-elastic:elasticsearch \
|
--link=fabmanager-elastic:elasticsearch \
|
||||||
-e RAILS_ENV=production \
|
-e RAILS_ENV=production \
|
||||||
-e RACK_ENV=production \
|
-e RACK_ENV=production \
|
||||||
--env-file /home/core/fabmanager/config/env \
|
--env-file /home/core/fabmanager/config/env \
|
||||||
-v /home/core/fabmanager/config/nginx:/etc/nginx/conf.d \
|
|
||||||
-v /home/core/fabmanager/public/assets:/usr/src/app/public/assets \
|
-v /home/core/fabmanager/public/assets:/usr/src/app/public/assets \
|
||||||
-v /home/core/fabmanager/public/uploads:/usr/src/app/public/uploads \
|
-v /home/core/fabmanager/public/uploads:/usr/src/app/public/uploads \
|
||||||
-v /home/core/fabmanager/invoices:/usr/src/app/invoices \
|
-v /home/core/fabmanager/invoices:/usr/src/app/invoices \
|
||||||
-v /home/core/fabmanager/exports:/usr/src/app/exports \
|
-v /home/core/fabmanager/exports:/usr/src/app/exports \
|
||||||
-v /home/core/fabmanager/plugins:/usr/src/app/plugins \
|
-v /home/core/fabmanager/plugins:/usr/src/app/plugins \
|
||||||
-v /home/core/fabmanager/log:/var/log/supervisor \
|
-v /home/core/fabmanager/log:/var/log/supervisor \
|
||||||
-v /home/core/fabmanager/letsencrypt/etc:/etc/letsencrypt \
|
|
||||||
sleede/fab-manager
|
sleede/fab-manager
|
||||||
|
|
||||||
|
docker run --restart=always -d --name=nginx \
|
||||||
|
-p 80:80 \
|
||||||
|
-p 443:443 \
|
||||||
|
--link=fabmanager:fabmanager \
|
||||||
|
-v /home/core/fabmanager/config/nginx:/etc/nginx/conf.d \
|
||||||
|
-v /home/core/fabmanager/letsencrypt/etc:/etc/letsencrypt \
|
||||||
|
-v /home/core/fabmanager/log:/var/log/nginx \
|
||||||
|
--volumes-from fabmanager:ro
|
||||||
|
nginx:1.9
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,40 +5,50 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
RAILS_ENV: production
|
RAILS_ENV: production
|
||||||
RACK_ENV: production
|
RACK_ENV: production
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
- "443:443"
|
|
||||||
env_file:
|
env_file:
|
||||||
- /home/core/fabmanager/config/env
|
- /home/core/fabmanager/config/env
|
||||||
volumes:
|
volumes:
|
||||||
- /home/core/fabmanager/config/nginx:/etc/nginx/conf.d
|
|
||||||
- /home/core/fabmanager/public/assets:/usr/src/app/public/assets
|
- /home/core/fabmanager/public/assets:/usr/src/app/public/assets
|
||||||
- /home/core/fabmanager/public/uploads:/usr/src/app/public/uploads
|
- /home/core/fabmanager/public/uploads:/usr/src/app/public/uploads
|
||||||
- /home/core/fabmanager/invoices:/usr/src/app/invoices
|
- /home/core/fabmanager/invoices:/usr/src/app/invoices
|
||||||
- /home/core/fabmanager/exports:/usr/src/app/exports
|
- /home/core/fabmanager/exports:/usr/src/app/exports
|
||||||
- /home/core/fabmanager/log:/var/log/supervisor
|
- /home/core/fabmanager/log:/var/log/supervisor
|
||||||
- /home/core/fabmanager/plugins:/usr/src/app/plugins
|
- /home/core/fabmanager/plugins:/usr/src/app/plugins
|
||||||
- /home/core/fabmanager/letsencrypt/etc:/etc/letsencrypt
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- fabmanager-postgres
|
- postgres
|
||||||
- fabmanager-redis
|
- redis
|
||||||
- fabmanager-elastic
|
- elasticsearch
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
fabmanager-postgres:
|
postgres:
|
||||||
image: postgres:9.4
|
image: postgres:9.4
|
||||||
volumes:
|
volumes:
|
||||||
- /home/core/fabmanager/postgresql:/var/lib/postgresql/data
|
- /home/core/fabmanager/postgresql:/var/lib/postgresql/data
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
fabmanager-elastic:
|
elasticsearch:
|
||||||
image: elasticsearch:1.7
|
image: elasticsearch:1.7
|
||||||
volumes:
|
volumes:
|
||||||
- /home/core/fabmanager/elasticsearch:/usr/share/elasticsearch/data
|
- /home/core/fabmanager/elasticsearch:/usr/share/elasticsearch/data
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
fabmanager-redis:
|
redis:
|
||||||
image: redis:3.0
|
image: redis:3.0
|
||||||
volumes:
|
volumes:
|
||||||
- /home/core/fabmanager/redis:/data
|
- /home/core/fabmanager/redis:/data
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.9
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
volumes:
|
||||||
|
- /home/core/fabmanager/config/nginx:/etc/nginx/conf.d
|
||||||
|
- /home/core/fabmanager/letsencrypt/etc:/etc/letsencrypt
|
||||||
|
- /home/core/suez-efw/log:/var/log/nginx
|
||||||
|
volumes_form:
|
||||||
|
- fabmanager:ro
|
||||||
|
links:
|
||||||
|
- fabmanager:fabmanager
|
||||||
|
restart: always
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
upstream puma {
|
upstream puma {
|
||||||
server unix:/usr/src/app/tmp/sockets/fabmanager.sock fail_timeout=0;
|
server fabmanager:3000;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
upstream puma {
|
upstream puma {
|
||||||
server unix:/usr/src/app/tmp/sockets/fabmanager.sock fail_timeout=0;
|
server fabmanager:3000;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
@ -14,13 +14,8 @@ childlogdir=/var/log/supervisor/ ; where child log files will liv
|
|||||||
[supervisorctl]
|
[supervisorctl]
|
||||||
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
|
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
|
||||||
|
|
||||||
[program:nginx]
|
|
||||||
command=nginx -g "daemon off;"
|
|
||||||
stderr_logfile=/var/log/supervisor/nginx-stderr.log
|
|
||||||
stdout_logfile=/var/log/supervisor/nginx-stdout.log
|
|
||||||
|
|
||||||
[program:app]
|
[program:app]
|
||||||
command=bundle exec puma -b unix:///usr/src/app/tmp/sockets/fabmanager.sock --pidfile /usr/src/app/tmp/pids/fabmanager.pid
|
command=bundle exec rails s puma -p 3000 -b 0.0.0.0
|
||||||
stderr_logfile=/var/log/supervisor/app-stderr.log
|
stderr_logfile=/var/log/supervisor/app-stderr.log
|
||||||
stdout_logfile=/var/log/supervisor/app-stdout.log
|
stdout_logfile=/var/log/supervisor/app-stdout.log
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user