Skip to content

Instantly share code, notes, and snippets.

@Servuc
Last active October 10, 2019 19:26
Show Gist options
  • Save Servuc/a63fbe84bdafa614e4cdff9debf2bb81 to your computer and use it in GitHub Desktop.
Save Servuc/a63fbe84bdafa614e4cdff9debf2bb81 to your computer and use it in GitHub Desktop.
docker-swarm
version: '3'
services:
webapp:
image: YOUR_PHP
ports:
- 12345:12345
deploy:
replicas: 10
restart_policy:
max_attempts: 3
condition: on-failure
update_config:
parallelism: 2
delay: 1m
networks:
- balance
proxy:
image: YOUR_NGINX
ports:
- 80:80
depends_on:
- webapp
deploy:
placement:
constraints: [node.role == manager]
networks:
- balance
networks:
balance:
driver: overlay
http {
upstream myCluster {
server IP_1:1324;
server IP_2:1234;
server IP_n:1234;
}
server {
listen 80;
location / {
proxy_pass http://myCluster;
}
}
}
FROM nginx
COPY nginx.conf /etc/nginx/conf.d/
EXPOSE 80
FROM php:cli-alpine
RUN echo "<?php echo gethostname() . ' - ' . gethostbyname(gethostname()) . ' - Version 1';" > index.php
EXPOSE 12345
CMD php -S 0.0.0.0:12345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment