Skip to content

Commit c557486

Browse files
committed
Update deployment script
1 parent 41e444f commit c557486

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ FROM alpine:3.8 as final
1313
# Install the cloudposse alpine repository
1414
ADD https://apk.cloudposse.com/[email protected] /etc/apk/keys/
1515
RUN echo "@cloudposse https://apk.cloudposse.com/3.8/vendor" >> /etc/apk/repositories
16+
RUN apk add --update variant@cloudposse
1617

1718
# Expose port of the app
1819
EXPOSE 8080

deploy/ctl

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
#!/usr/bin/env variant
22
# vim:set ft=yaml
3+
4+
parameters:
5+
- name: config
6+
default: .color
7+
description: "Config file that keeps track of the current color"
8+
9+
options:
10+
- name: debug
11+
default: boolean
12+
default: false
13+
description: "Enable debug mode"
14+
315
tasks:
16+
417
deps:
518
description: "Install alpine dependencies"
619
script: |
7-
apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse
20+
! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse
821

922
color:
1023
description: "Lookup the current color"
11-
12-
parameters:
13-
- name: config
14-
default: ".color"
15-
description: "Config file that keeps track of the current color"
16-
1724
script: |
1825
config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
1926
if [ -f ${config} ]; then
2027
cat ${config}
2128
else
2229
echo "blue" | tee ${config}
2330
fi
31+
2432
blue-green:
2533
description: "Trigger a blue-green deployment"
2634

2735
parameters:
2836
- name: namespace
2937
default: "default"
3038
description: "Kubernetes namespace"
31-
32-
- name: config
33-
default: ".color"
34-
description: "Config file that keeps track of the current color"
3539

3640
- name: color
3741
type: string
@@ -46,12 +50,15 @@ tasks:
4650
type: string
4751
default: blue
4852
description: "Flip green color to this color"
49-
50-
script: |
51-
config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
52-
cur_color={{ get "color" }}
53-
new_color={{ get "color" | get }}
54-
echo "Updating {{ get "namespace" }}: $cur_color => $new_color"
55-
echo "$new_color" > ${config}
56-
export COLOR=$new_color
57-
helmfile --namespace {{ get "namespace" }} sync
53+
54+
steps:
55+
- task: deps
56+
- script: |
57+
config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
58+
cur_color={{ get "color" }}
59+
new_color={{ get "color" | get }}
60+
echo "Config file is ${config}"
61+
echo "Updating {{ get "namespace" }}: $cur_color => $new_color"
62+
echo "$new_color" > ${config}
63+
export COLOR=$new_color
64+
helmfile --namespace {{ get "namespace" }} sync

0 commit comments

Comments
 (0)