-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
67 lines (62 loc) · 1.98 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
version: '3'
# use custom network to prevent add prefix to the network
networks:
nginx-alpine-network:
name: nginx-alpine-network
driver: bridge
services:
nginx:
# image: nginx:stable-alpine has an error because www-data user is not created on the default image
container_name: nginx-alpine-server
build: ./docker/nginx-alpine
image: nginx-alpine-server
restart: unless-stopped
ports:
- "80:80"
- "443:443"
# reload every 6 hours when nginx renovation will be needed
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
working_dir: /etc/nginx
volumes:
# reemplazamos la instalación de nginx
- ./nginx:/etc/nginx
# conectamos los certificados con el host
- ./certbot/conf:/etc/letsencrypt
# .well-known directory keys
- ./certbot/www:/var/www/certbot
- ./log/nginx:/var/log/nginx
- ./log/letsencrypt:/var/log/letsencrypt
# apps directory depends on conf.d files to link to this directory
- ./apps:/var/www/apps
networks:
- nginx-alpine-network
depends_on:
- certbot
certbot:
container_name: nginx-alpine-certbot
image: nginx-alpine-certbot
build: ./docker/certbot
restart: unless-stopped
# automatic check renovation needed every 12 hours
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
working_dir: /etc/letsencrypt
volumes:
- ./certbot/conf:/etc/letsencrypt
# .well-known directory
- ./certbot/www:/var/www/certbot
networks:
- nginx-alpine-network
# add profiles to deploy another containers working with nginx
# docker compose --profile php up
php:
profiles:
- php
image: nginx-alpine-php
build: ./docker/php/7.4-fpm-alpine
container_name: nginx-alpine-php
ports:
- "9001:9000"
volumes:
- ./apps:/var/www/apps
networks:
- nginx-alpine-network