You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 3) ''/var/web/project/spring-sample-h-auth' is here as well. The thing is you should locate 'application.properties', 'logback-spring.xml', 'yourdomain.com.jks' on the './src/main/resource' folder.
Copy file name to clipboardExpand all lines: README.md
+68-49Lines changed: 68 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,8 @@
2
2
3
3
> One Simple Zero-Downtime Blue-Green Deployment with your Dockerfiles
4
4
5
-
Deploying web projects should be [simple, with high availability and security](https://github.com/Andrew-Kang-G/docker-blue-green-runner?tab=readme-ov-file#Quick-Guide-on-Usage).
6
-
7
-
- Use ``the latest Release version`` OR at least ``tagged versions`` for your production, NOT the latest commit of the 'main' branch.
8
-
- In production, place your project in a separate folder, not in the samples folder, as they are just examples.
9
-
10
5
## Table of Contents
6
+
-[Process Summary](#process-summary)
11
7
-[Features](#features)
12
8
-[Requirements](#requirements)
13
9
-[Quick Start with Samples](#quick-start-with-samples)
@@ -34,8 +30,7 @@ Deploying web projects should be [simple, with high availability and security](h
34
30
-[Consul](#consul)
35
31
-[USE_NGINX_RESTRICTION on .env](#use_nginx_restriction-on-env)
-[Upload Image (CI/CD Server -> Git)](#upload-image-cicd-server---git)
40
35
-[Download Image (Git -> Production Server)](#download-image-git---production-server)
41
36
-[Extra Information](#extra-information)
@@ -47,6 +42,44 @@ Deploying web projects should be [simple, with high availability and security](h
47
42
48
43
---
49
44
45
+
## Process Summary
46
+
47
+
- Term Reference
48
+
-``All`` means below is "App", "Nginx", "Consul&Registrator".
49
+
-``(Re)Load`` means ``docker run.... OR docker-compose up``.
50
+
-``State`` is ``Blue`` or ``Green``
51
+
- More is on [Terms](#terms)
52
+
- Load Consul & Registrator, then the App, and finally Nginx to prevent upstream errors.
53
+
54
+
55
+
```mermaid
56
+
graph TD;
57
+
A[Initialize and Set Variables] --> B[Backup All Images]
58
+
B --> C[Check the .env File Integrity]
59
+
C --> D[Build All Images]
60
+
D --> E[Create Consul Network]
61
+
E --> F{Reload Consul if Required}
62
+
F -- Yes --> G[Reload Consul]
63
+
F -- No --> H[Load Your App]
64
+
G --> H[Load Your App]
65
+
H --> I[Check App Integrity]
66
+
I --> J{Reload Nginx if Required}
67
+
J -- Yes --> K[Check Nginx Template Integrity by Running a Test Container]
68
+
J -- No --> L[Check All Containers' Health]
69
+
K --> L[Check All Containers' Health]
70
+
L --> M{Set New State Using Consul Template}
71
+
M -- Fails --> O[Run Nginx Contingency Plan]
72
+
M -- Success --> N[External Integrity Check]
73
+
O --> N[External Integrity Check]
74
+
N -- Fails --> P[Rollback App if Needed]
75
+
N -- Success --> Q["Remove the Opposite State (Blue or Green) from the Running Containers"]
76
+
P --> Q["Remove the Opposite State from the Running Containers"]
77
+
Q --> R[Clean Up Dangling Images]
78
+
R --> S[Deployment Complete]
79
+
80
+
```
81
+

82
+

50
83
## Features
51
84
52
85
-**No Unpredictable Errors in Reverse Proxy and Deployment**
@@ -58,6 +91,7 @@ Deploying web projects should be [simple, with high availability and security](h
58
91
59
92
-**From Scratch**
60
93
- Docker-Blue-Green-Runner's `run.sh` script is designed to simplify deployment: "With your `.env`, project, and a single Dockerfile, simply run 'bash run.sh'." This script covers the entire process from Dockerfile build to server deployment from scratch.
94
+
- This means you can easily migrate to another server with just the files mentioned above.
61
95
- In contrast, Traefik requires the creation and gradual adjustment of various configuration files, which can introduce the types of errors mentioned above.
62
96
63
97
- Focus on zero-downtime deployment on a single machine.
@@ -105,10 +139,10 @@ Deploying web projects should be [simple, with high availability and security](h
105
139
| git | N/A | Manual | - |
106
140
| bash | 4.4 at least | Manual | - |
107
141
| curl | N/A | Manual | - |
108
-
| yq | 4.35.1 |Manual| Use v4.35.1 instead of the latest version. The lastest version causes a parsing error |
142
+
| yq | 4.35.1 |Auto | Use v4.35.1 instead of the latest version. The lastest version causes a parsing error |
109
143
| consul (docker image) | 1.14.11 | Auto | An error occurred due to a payload format issue while the lastest version of it was communicating with gliderlabs/registrator. |
110
144
| gliderlabs/registrator (docker image) | master | Auto ||
111
-
| nginx (docker image) |latest| Auto | Considering changing it to a certain version, but until now no issues have been detected. |
145
+
| nginx (docker image) |1.25.4| Auto | Considering changing it to a certain version, but until now no issues have been detected. |
112
146
| docker | 24~27 | Manual | I think too old versions could cause problems, and the lastest version v27.x causes only a warning message. |
113
147
| docker-compose | 2 | Manual | I think too old versions could cause problems, and the v2 is recommended. |
- Additionally, the APP_URL parameter is used for 'check_availability_out_of_container' at [Structure](#Structure)
312
+
- Additionally, the `APP_URL` parameter is used for the ["External Integrity Check"](#process-summary) process.
279
313
- You can set it as https://localhost:13000 or https://your-domain:13000 for production environments. (Both configurations are acceptable)
280
314
- Moreover, the Runner parses the protocol (http or https), and if it is https, it checks for SSL certificates in the .docker/ssl directory on the host according to the following settings:
281
315
- ```shell
@@ -288,9 +322,23 @@ sudo bash run.sh
288
322
# Set this to 'real' in the .env file for production environments.
289
323
APP_ENV=real
290
324
325
+
# This path is used for both internal and external health checks.
326
+
# Note: Do not include a leading slash ("/") at the start of the path.
# If APP_ENV is set to 'local', as specified in 'docker-compose-app-local-original.yml', synchronize your entire project as follows: "HOST_ROOT_LOCATION:PROJECT_LOCATION".
295
343
# [IMPORTANT] If this is set to true, Nginx will be restarted, resulting in a short downtime.
296
344
# This option should be used when upgrading the Runner. See the "Upgrade" section below.
@@ -299,6 +347,10 @@ NGINX_RESTART=false
299
347
# Setting this to 'true' is not recommended for normal operation as it results in prolonged downtime.
300
348
CONSUL_RESTART=false
301
349
350
+
# Specify the location of the .git folder for your project here to enable tracking through container labels.
351
+
# To track, simply run `bash check-current_states.sh`.
352
+
DOCKER_BUILD_SHA_INSERT_GIT_ROOT=
353
+
302
354
# Not recommended for normal operation as it leads to a long downtime.
303
355
# If this is set to true, it entails running 'stop-all-containers.sh & remove-all-images.sh'.
304
356
# In case your project is renamed or moved to another folder, Docker may not work properly.
@@ -402,6 +454,8 @@ bash check-current-states.sh
402
454
[DEBUG] ! Checked which (Blue OR Green) is currently running... (Final Check) : blue_score : 130, green_score : 27, state : blue, new_state : green, state_for_emergency : blue, new_upstream : https://PROJECT_NAME:8300.
403
455
```
404
456
- The higher the score a state receives, the more likely it is to be the currently running state. So the updated App should be deployed as the non-occupied state(new_state).
457
+
458
+
- 
405
459
406
460
### Emergency
407
461
- Nginx (like when Nginx is NOT booted OR 502 error...)
- **For the properties of 'environment, volumes', use .env instead of setting them on the yml.**
492
546
- Set ```USE_MY_OWN_APP_YML=true``` on .env
493
547
- ```bash run.sh```
494
-
495
-
## Process Summary
496
-
497
-
- Term Reference
498
-
- ``All`` means below is "App", "Nginx", "Consul&Registrator".
499
-
- ``(Re)Load`` means ``docker run.... OR docker-compose up``.
500
-
- ``State`` is ``Blue`` or ``Green``
501
-
- More is on [Terms](#terms)
502
-
- Load Consul & Registrator, then the App, and finally Nginx to prevent upstream errors.
503
548
504
549
505
-
```mermaid
506
-
graph TD;
507
-
A[Initialize and Set Variables] --> B[Backup All Images]
508
-
B --> C[Check the .env File Integrity]
509
-
C --> D[Build All Images]
510
-
D --> E[Create Consul Network]
511
-
E --> F{Reload Consul if Required}
512
-
F -- Yes --> G[Reload Consul]
513
-
F -- No --> H[Load Your App]
514
-
G --> H[Load Your App]
515
-
H --> I[Check App Integrity]
516
-
I --> J{Reload Nginx if Required}
517
-
J -- Yes --> K[Check Nginx Template Integrity by Running a Test Container]
518
-
J -- No --> L[Check All Containers' Health]
519
-
K --> L[Check All Containers' Health]
520
-
L --> M{Set New State Using Consul Template}
521
-
M -- Fails --> O[Run Nginx Contingency Plan]
522
-
M -- Success --> N[External Integrity Check]
523
-
O --> N[External Integrity Check]
524
-
N -- Fails --> P[Rollback App if Needed]
525
-
N -- Success --> Q["Remove the Opposite State (Blue or Green) from the Running Containers"]
526
-
P --> Q["Remove the Opposite State from the Running Containers"]
527
-
Q --> R[Clean Up Dangling Images]
528
-
R --> S[Deployment Complete]
529
-
530
-
```
531
-
## Gitlab Container Registry
550
+
## Gitlab Container Registry (Production)
532
551
533
552
### Upload Image (CI/CD Server -> Git)
534
553
- In case you run the command ``push-to-git.sh``, ``docker-blue-green-runner`` pushes one of ``Blue or Green`` images which is currently running to the address above of the Gitlab Container Registry.
@@ -593,4 +612,4 @@ git status # If any changes are detected, the source code may be corrupted.
0 commit comments