Skip to content

Instantly share code, notes, and snippets.

@markotom
Created October 28, 2019 21:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markotom/9e0fdbbfeac76667169d4ea32a89ce83 to your computer and use it in GitHub Desktop.
Save markotom/9e0fdbbfeac76667169d4ea32a89ce83 to your computer and use it in GitHub Desktop.
docker compose & marble seeds

Just run:

$ docker network create marbleseeds-network
$ docker volume create --name=mongodbdata
$ docker-compose up -d
# nginx/conf.d/default.conf
upstream apiServer {
server api:3000;
}
upstream appServer {
server app:4000;
}
upstream adminServer {
server admin:5000;
}
server {
listen 80 default_server;
server_name _;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
client_max_body_size 0;
location /api {
client_max_body_size 0;
proxy_pass http://apiServer;
proxy_redirect off;
proxy_read_timeout 5m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
client_max_body_size 0;
proxy_pass http://appServer/;
proxy_redirect off;
proxy_read_timeout 5m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /admin {
client_max_body_size 0;
proxy_pass http://adminServer;
proxy_redirect off;
proxy_read_timeout 5m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
version: '3'
services:
api:
container_name: api
restart: always
build: .
ports:
- "3000:3000"
networks:
- marbleseeds-network
volumes:
- .:/marbleseeds
links:
- mongo
app:
container_name: app
restart: always
build: .
ports:
- "4000:4000"
networks:
- marbleseeds-network
volumes:
- .:/marbleseeds
admin:
container_name: admin
restart: always
build: .
ports:
- "5000:5000"
networks:
- marbleseeds-network
volumes:
- .:/marbleseeds
mongo:
container_name: mongo
image: mongo
ports:
- "27017:27017"
networks:
- marbleseeds-network
volumes:
- mongodbdata:/data/db
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
networks:
- marbleseeds-network
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
volumes:
mongodbdata:
external: true
networks:
marbleseeds-network:
external: true
FROM node:8-alpine
RUN apk add python gcc g++ make curl
ARG WORKING_DIR=/var/www
RUN mkdir -p $WORKING_DIR
WORKDIR $WORKING_DIR
COPY package.json $WORKING_DIR
RUN npm install
COPY . $WORKING_DIR/
RUN make dist
RUN npm install -g pm2
RUN pm2 install pm2-logrotate
CMD ["pm2-runtime", "ecosystem.config.js", "--env", "production"]
module.exports = {
apps : [{
name: 'API',
script: './api/runner.js',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}, {
name: 'App',
script: './app/runner.js',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}, {
name: 'Admin',
script: './admin/runner.js',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment