|
1 | 1 | services: |
| 2 | + app: |
| 3 | + profiles: |
| 4 | + - prod |
| 5 | + - dev |
| 6 | + build: |
| 7 | + context: . |
| 8 | + dockerfile: Dockerfile |
| 9 | + image: ${DOCKER_USERNAME}/${PACKAGE_NAME}:${PACKAGE_VERSION} |
| 10 | + container_name: ${PACKAGE_NAME}_api |
| 11 | + environment: |
| 12 | + - PORT=${PORT} |
| 13 | + - NODE_ENV=${NODE_ENV} |
| 14 | + - EMAIL=${EMAIL} |
| 15 | + - BASE_URL=${BASE_URL} |
| 16 | + - HOST_PROJECT_ROOT=${PWD} |
| 17 | + ports: |
| 18 | + - "5000:${PORT}" |
| 19 | + volumes: |
| 20 | + - /var/run/docker.sock:/var/run/docker.sock |
| 21 | + - ./temp:/app/temp |
| 22 | + networks: |
| 23 | + - default |
| 24 | + restart: unless-stopped |
| 25 | + |
| 26 | + healthcheck: |
| 27 | + test: ["CMD", "curl", "-f", "http://localhost:${PORT}/"] |
| 28 | + interval: 30s # Check every 15 seconds (more frequent) |
| 29 | + timeout: 15s # 10 second timeout |
| 30 | + retries: 3 # 3 retries before marking unhealthy |
| 31 | + start_period: 30s # Wait 30 seconds before starting health checks |
| 32 | + |
| 33 | + # Add logging configuration |
| 34 | + logging: |
| 35 | + driver: "json-file" |
| 36 | + options: |
| 37 | + max-size: "10m" |
| 38 | + max-file: "3" |
| 39 | + # Add labels for better container management |
| 40 | + labels: |
| 41 | + - "app.name=${PACKAGE_NAME}" |
| 42 | + - "app.version=${PACKAGE_VERSION}" |
| 43 | + - "deployment.type=zero-downtime" |
| 44 | + |
| 45 | + nginx: |
| 46 | + profiles: |
| 47 | + - prod |
| 48 | + image: nginx:alpine |
| 49 | + container_name: ${PACKAGE_NAME}_nginx |
| 50 | + depends_on: |
| 51 | + - app |
| 52 | + volumes: |
| 53 | + - ./nginx/conf.d:/etc/nginx/conf.d |
| 54 | + - ./nginx/certbot/www:/var/www/certbot |
| 55 | + - ./nginx/certbot/conf:/etc/letsencrypt |
| 56 | + - ./nginx/selfsigned:/etc/nginx/selfsigned |
| 57 | + |
| 58 | + ports: |
| 59 | + - "80:80" |
| 60 | + - "443:443" |
| 61 | + networks: |
| 62 | + - default |
| 63 | + restart: always |
| 64 | + |
| 65 | + certbot: |
| 66 | + profiles: |
| 67 | + - prod |
| 68 | + image: certbot/certbot |
| 69 | + container_name: ${PACKAGE_NAME}_certbot |
| 70 | + volumes: |
| 71 | + - ./nginx/certbot/www:/var/www/certbot |
| 72 | + - ./nginx/certbot/conf:/etc/letsencrypt |
| 73 | + environment: |
| 74 | + - EMAIL=${EMAIL} |
| 75 | + - BASE_URL=${BASE_URL} |
| 76 | + entrypoint: > |
| 77 | + certbot certonly --webroot --webroot-path=/var/www/certbot |
| 78 | + --email ${EMAIL} --agree-tos --no-eff-email |
| 79 | + -d ${BASE_URL} |
| 80 | + depends_on: |
| 81 | + - nginx |
| 82 | + networks: |
| 83 | + - default |
| 84 | + restart: "no" |
| 85 | + |
| 86 | + certbot-renew: |
| 87 | + profiles: |
| 88 | + - prod |
| 89 | + image: certbot/certbot |
| 90 | + container_name: ${PACKAGE_NAME}_certbot_renew |
| 91 | + volumes: |
| 92 | + - ./nginx/certbot/www:/var/www/certbot |
| 93 | + - ./nginx/certbot/conf:/etc/letsencrypt |
| 94 | + entrypoint: > |
| 95 | + sh -c "trap exit TERM; |
| 96 | + while :; do |
| 97 | + echo '🔄 Checking for SSL renewal...'; |
| 98 | + certbot renew --webroot --webroot-path=/var/www/certbot --quiet --deploy-hook 'nginx -s reload'; |
| 99 | + sleep 12h; |
| 100 | + done" |
| 101 | + depends_on: |
| 102 | + - nginx |
| 103 | + networks: |
| 104 | + - default |
| 105 | + restart: unless-stopped |
| 106 | + |
| 107 | + # ====================== language image ====================== # |
2 | 108 | nodejs-image: |
3 | | - profile: |
| 109 | + profiles: |
4 | 110 | - prod |
5 | 111 | build: |
6 | 112 | context: . |
7 | 113 | dockerfile: docker/Dockerfile.nodejs |
8 | 114 | image: executor-nodejs:latest |
9 | 115 |
|
10 | 116 | deno-image: |
11 | | - profile: |
| 117 | + profiles: |
12 | 118 | - prod |
13 | 119 | build: |
14 | 120 | context: . |
15 | 121 | dockerfile: docker/Dockerfile.deno |
16 | 122 | image: executor-deno:latest |
17 | 123 |
|
18 | 124 | python-image: |
19 | | - profile: |
| 125 | + profiles: |
20 | 126 | - prod |
21 | 127 | build: |
22 | 128 | context: . |
23 | 129 | dockerfile: docker/Dockerfile.python |
24 | 130 | image: executor-python:latest |
25 | 131 |
|
26 | 132 | java-image: |
27 | | - profile: |
| 133 | + profiles: |
28 | 134 | - prod |
29 | 135 | build: |
30 | 136 | context: . |
31 | 137 | dockerfile: docker/Dockerfile.jvm |
32 | 138 | image: executor-java:latest |
33 | 139 |
|
34 | 140 | kotlin-image: |
35 | | - profile: |
| 141 | + profiles: |
36 | 142 | - prod |
37 | 143 | build: |
38 | 144 | context: . |
39 | 145 | dockerfile: docker/Dockerfile.kotlin |
40 | 146 | image: executor-kotlin:latest |
41 | 147 |
|
42 | | - nodejs-server-image: |
43 | | - profile: |
44 | | - - prod |
45 | | - - dev |
46 | | - build: |
47 | | - context: . |
48 | | - dockerfile: Dockerfile |
49 | | - image: nodejs-server-image:latest |
50 | | - environment: |
51 | | - - PORT=9091 |
52 | | - - HOST_PROJECT_ROOT=${PWD} |
53 | | - ports: |
54 | | - - "9091:9091" |
55 | | - volumes: |
56 | | - - /var/run/docker.sock:/var/run/docker.sock |
57 | | - - ./temp:/app/temp |
58 | | - networks: |
59 | | - - app-network |
60 | | - restart: unless-stopped |
61 | | - |
62 | | - executeme-nginx: |
63 | | - profile: |
64 | | - - prod |
65 | | - image: nginx:alpine |
66 | | - ports: |
67 | | - - "9292:9292" |
68 | | - volumes: |
69 | | - - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro |
70 | | - - ./nginx/certs:/etc/nginx/certs:ro |
71 | | - depends_on: |
72 | | - - nodejs-server-image |
73 | | - networks: |
74 | | - - app-network |
75 | | - restart: unless-stopped |
76 | | - |
77 | 148 | networks: |
78 | | - app-network: |
79 | | - driver: bridge |
| 149 | + default: |
| 150 | + name: ${PACKAGE_NAME}_network |
| 151 | + labels: |
| 152 | + - "project=${PACKAGE_NAME}" |
0 commit comments