Skip to content

Instantly share code, notes, and snippets.

@Servuc
Last active Oct 10, 2019
Embed
What would you like to do?
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