Skip to content

Commit 6dfdc61

Browse files
committed
feat: linux provider basic auth
1 parent b0db435 commit 6dfdc61

File tree

5 files changed

+58
-29
lines changed

5 files changed

+58
-29
lines changed

docker-compose-remote.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ services:
1010
networks:
1111
- default
1212
ports:
13-
- "__PORT__:80"
13+
- "_PORT_:80"
1414
secrets:
1515
- BASIC_AUTH_HTPASSWD
1616
volumes:
1717
- "./docker-nginx.conf:/etc/nginx/nginx.conf:delegated"
1818

1919
server-template-admin:
2020
container_name: server-template-admin
21-
image: host/server-template/admin:__IMAGE_TAG__
21+
image: host/server-template/admin:_IMAGE_TAG_
2222
restart: unless-stopped
2323
networks:
2424
- default
@@ -30,7 +30,7 @@ services:
3030

3131
server-template-client:
3232
container_name: server-template-client
33-
image: host/server-template/client:__IMAGE_TAG__
33+
image: host/server-template/client:_IMAGE_TAG_
3434
restart: unless-stopped
3535
networks:
3636
- default
@@ -46,7 +46,7 @@ services:
4646

4747
server-template-graphql:
4848
container_name: server-template-graphql
49-
image: host/server-template/graphql:__IMAGE_TAG__
49+
image: host/server-template/graphql:_IMAGE_TAG_
5050
restart: unless-stopped
5151
networks:
5252
- default
@@ -69,7 +69,7 @@ services:
6969

7070
server-template-server:
7171
container_name: server-template-server
72-
image: host/server-template/server:__IMAGE_TAG__
72+
image: host/server-template/server:_IMAGE_TAG_
7373
restart: unless-stopped
7474
networks:
7575
- default
@@ -104,7 +104,7 @@ services:
104104

105105
server-template-www:
106106
container_name: server-template-www
107-
image: host/server-template/www:__IMAGE_TAG__
107+
image: host/server-template/www:_IMAGE_TAG_
108108
restart: unless-stopped
109109
networks:
110110
- default

docker-nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ http {
2020
server_name localhost;
2121
client_max_body_size 32m;
2222

23-
# auth_basic “user”;
24-
# auth_basic_user_file /etc/nginx/.htpasswd;
23+
# auth_basic "basic";
24+
# auth_basic_user_file /run/secrets/BASIC_AUTH_HTPASSWD;
2525

2626
location /graphql {
2727
proxy_pass http://server-template-graphql:8080;

scripts/linux-provider/taito-deployment-deploy#post.sh

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@
66
: "${taito_namespace:?}"
77
: "${taito_target_env:?}"
88
: "${taito_branch:?}"
9+
: "${taito_container_registry:?}"
10+
: "${taito_project:?}"
11+
: "${taito_basic_auth_enabled:?}"
912

1013
set -e
1114

1215
image_tag=$1
1316
if [[ ! $image_tag ]]; then
17+
echo "[Getting commit sha of the latest commit on branch ${taito_branch}]"
1418
image_tag=$(git rev-parse "${taito_branch}")
19+
echo "Commit SHA: ${image_tag}"
20+
echo
1521
fi
1622

1723
# Add untested prefix
18-
if [[ "${ci_exec_build:-}" == "true" ]]; then
24+
if [[ "${ci_exec_build:-}" == "true" ]] && [[ ${image_tag} != *"-untested" ]]; then
1925
image_tag="${image_tag}-untested"
2026
fi
2127

2228
echo "[Starting deployment of image $image_tag]"
23-
echo
2429
echo "NOTE: Deployment is done using the taito-config.sh and"
2530
echo "docker-compose-remote.yaml currently located on your local directory."
2631
echo
@@ -38,39 +43,60 @@ echo "[Copy docker-compose-remote.yaml to ${taito_host}:/tmp]"
3843
)
3944
echo
4045

41-
echo "[Execute on ${taito_host}]"
46+
echo "[Execute on host ${taito_host}]"
4247
ssh ${opts} "${taito_ssh_user}@${taito_host}" "
4348
sudo bash -c '
4449
set -e
4550
${taito_setv:?}
4651
cd ${taito_host_dir}
4752
echo
48-
echo [Extract /tmp/${taito_namespace}.tar]
53+
echo [Check that Docker images exist]
54+
if ! sudo docker images | grep ${taito_container_registry} | grep ${image_tag} &> /dev/null; then
55+
echo Latest images on remote host:
56+
sudo docker images | grep ${taito_container_registry}
57+
echo
58+
echo ERROR: No image with tag ${image_tag}
59+
exit 1
60+
fi
61+
echo
62+
echo [Extract configuration files from /tmp/${taito_namespace}.tar]
4963
tar -xf /tmp/${taito_namespace}.tar -C .
5064
rm -f /tmp/${taito_namespace}.tar
51-
mv -f docker-compose-remote.yaml docker-compose.yaml
5265
echo
53-
echo [Replace port and image tag in docker-compose.yaml]
66+
echo [Replace port and image tag in docker-compose-remote.yaml]
5467
PORT=\$(getsiteport ${taito_namespace})
55-
sed -i s/__PORT__/\${PORT}/ docker-compose.yaml
56-
sed -i s/__IMAGE_TAG__/${image_tag}/ docker-compose.yaml
68+
sed -i \"s/_PORT_/\${PORT}/g\" docker-compose-remote.yaml
69+
sed -i \"s/_IMAGE_TAG_/${image_tag}/g\" docker-compose-remote.yaml
5770
echo
71+
if [[ ${taito_basic_auth_enabled} != false ]]; then
72+
echo [Enable basic auth]
73+
sed -i \"s/# auth_basic/auth_basic/\" docker-nginx.conf
74+
if ! grep \"^[[:space:]]*auth_basic\" docker-nginx.conf &> /dev/null; then
75+
echo ERROR: Basic auth not enabled
76+
exit 1
77+
fi
78+
echo
79+
fi
5880
echo [Modify taito-config.sh]
59-
sed -i \"1 ataito_target_env=${taito_target_env}\" taito-config.sh
60-
sed -i \"1 aset -a\" taito-config.sh
61-
echo set +a >> taito-config.sh
81+
sed -i \"3 ataito_target_env=${taito_target_env}\" taito-config.sh
6282
sed -i /taito_util_path/d taito-config.sh
6383
echo
64-
echo [Set environment variables]
65-
. taito-config.sh
66-
echo
67-
echo [Pull new container images]
84+
echo [Pull container images using the new configuration]
6885
echo NOTE: Pulling of local-only images will print an error! This is OK.
69-
(docker-compose pull || :)
86+
(. taito-config.sh && docker-compose -f docker-compose-remote.yaml pull || :)
7087
echo
71-
echo [Restart docker-compose]
72-
docker-compose stop
88+
echo [Stop docker-compose using the old configuration]
89+
(. taito-config.sh && docker-compose stop)
90+
echo
91+
echo [Start docker-compose using the new configuration]
92+
. taito-config.sh
93+
mv -f docker-compose-remote.yaml docker-compose.yaml
7394
docker-compose up -d
7495
'
75-
"
96+
" || (
97+
echo "Recent commits in ${taito_target_env} branch:"
98+
git log -10 --pretty=oneline "${taito_target_env}"
99+
exit 1
100+
)
101+
76102
echo

scripts/linux-provider/taito-env-rotate#post.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ ssh ${opts} "${taito_ssh_user}@${taito_host}" "
3535
echo
3636
3737
echo [Restart docker-compose]
38-
docker-compose -f docker-compose-remote.yaml stop
39-
docker-compose -f docker-compose-remote.yaml -d up
38+
docker-compose -f docker-compose.yaml stop
39+
docker-compose -f docker-compose.yaml -d up
4040
'
4141
"
4242
echo

taito-config.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
# shellcheck disable=SC2034
3+
set -a
34
: "${taito_target_env:?}"
45

56
# Configuration instructions:
@@ -480,3 +481,5 @@ if [[ $taito_plugins == *"gcloud-ci"* ]] && [[ ${taito_mode:-} == "ci" ]]; then
480481
test_all_DATABASE_HOST=127.0.0.1
481482
test_all_DATABASE_PORT=5001
482483
fi
484+
485+
set +a

0 commit comments

Comments
 (0)