Skip to content

Commit 631d745

Browse files
authored
Merge pull request #2830 from cyberark/migrate-dockerv1-to-dockerv2
Change from docker-compose to docker compose in scripts
2 parents 2c20561 + ace5097 commit 631d745

File tree

11 files changed

+69
-69
lines changed

11 files changed

+69
-69
lines changed

UPGRADING.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ that was used when you originally deployed your Conjur server.
1919

2020
3. Pull the new Conjur image version:
2121
```
22-
docker-compose pull conjur
22+
docker compose pull conjur
2323
```
2424

2525
4. Stop the Conjur container:
2626
```
27-
docker-compose stop conjur
27+
docker compose stop conjur
2828
```
2929

3030
5. Bring up the Conjur service using the new image version without changing
3131
linked services:
3232
```
33-
docker-compose up -d --no-deps conjur
33+
docker compose up -d --no-deps conjur
3434
```
3535

3636
6. View Docker containers and verify all are healthy, up and running:
3737
```
38-
docker-compose ps -a
38+
docker compose ps -a
3939
```
4040

4141
It may also be useful to check if Conjur started successfully, which can be
4242
done by running
4343
```
44-
$ docker-compose exec conjur conjurctl wait
44+
$ docker compose exec conjur conjurctl wait
4545
Waiting for Conjur to be ready...
4646
...
4747
Conjur is ready!
@@ -56,7 +56,7 @@ environment variable first, you will be able to complete the steps without an
5656
visible/explicit error message, but the logs of the new Conjur container will
5757
show an error like:
5858
```
59-
$ docker-compose logs conjur_server
59+
$ docker compose logs conjur_server
6060
rake aborted!
6161
No CONJUR_DATA_KEY
6262
...
@@ -66,7 +66,7 @@ To fix this, set the `CONJUR_DATA_KEY` environment variable and run through
6666
the [process](#standard-process) again. This time when you check the logs of the Conjur server
6767
container you should see the service starting as expected:
6868
```
69-
$ docker-compose logs conjur_server
69+
$ docker compose logs conjur_server
7070
...
7171
=> Booting Puma
7272
=> Rails 5.2.4.3 application starting in production

ci/oauth/keycloak/keycloak_functions.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function _hydrate_keycloak_env_args() {
1616
set -o pipefail
1717
# Note: This prints all lines that look like:
1818
# KEYCLOAK_XXX=someval
19-
docker-compose exec -T ${KEYCLOAK_SERVICE_NAME} printenv | awk '/KEYCLOAK/'
19+
docker compose exec -T ${KEYCLOAK_SERVICE_NAME} printenv | awk '/KEYCLOAK/'
2020
)
2121

2222
# shellcheck disable=SC2034
@@ -34,22 +34,22 @@ function _hydrate_keycloak_env_args() {
3434
# _create_keycloak_user '$APP_USER' '$APP_PW' '$APP_EMAIL'
3535
#
3636
# This is because those variables are not available to this script. They are
37-
# available to bash commands run via "docker-compose exec keycloak bash
37+
# available to bash commands run via "docker compose exec keycloak bash
3838
# -c...", since they're defined in the docker-compose.yml.
3939
function _create_keycloak_user() {
4040
local user_var=$1
4141
local pw_var=$2
4242
local email_var=$3
4343

44-
docker-compose exec -T \
44+
docker compose exec -T \
4545
${KEYCLOAK_SERVICE_NAME} \
4646
bash -c "/scripts/create_user \"$user_var\" \"$pw_var\" \"$email_var\""
4747
}
4848

4949
function create_keycloak_users() {
5050
echo "Defining keycloak client"
5151

52-
docker-compose exec -T ${KEYCLOAK_SERVICE_NAME} /scripts/create_client
52+
docker compose exec -T ${KEYCLOAK_SERVICE_NAME} /scripts/create_client
5353

5454
echo "Creating user 'alice' in Keycloak"
5555

@@ -80,7 +80,7 @@ function create_keycloak_users() {
8080
}
8181

8282
function wait_for_keycloak_server() {
83-
docker-compose exec -T \
83+
docker compose exec -T \
8484
${KEYCLOAK_SERVICE_NAME} /scripts/wait_for_server
8585
}
8686

@@ -93,7 +93,7 @@ function fetch_keycloak_certificate() {
9393
read -ra parallel_services <<< "$(get_parallel_services 'conjur')"
9494

9595
for parallel_service in "${parallel_services[@]}"; do
96-
docker-compose exec -T \
96+
docker compose exec -T \
9797
"${parallel_service}" /oauth/keycloak/scripts/fetch_certificate
9898
done
9999
}

ci/shared.sh

+14-14
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ _run_cucumber_tests() {
6666
read -ra parallel_services <<< "$(get_parallel_services 'conjur pg')"
6767

6868
if (( ${#services[@]} )); then
69-
docker-compose up --no-deps --no-recreate -d "${parallel_services[@]}" "${services[@]}"
69+
docker compose up --no-deps --no-recreate -d "${parallel_services[@]}" "${services[@]}"
7070
else
71-
docker-compose up --no-deps --no-recreate -d "${parallel_services[@]}"
71+
docker compose up --no-deps --no-recreate -d "${parallel_services[@]}"
7272
fi
7373

7474
read -ra parallel_services <<< "$(get_parallel_services 'conjur')"
7575
for parallel_service in "${parallel_services[@]}"; do
76-
docker-compose exec -T "$parallel_service" conjurctl wait --retries 180
76+
docker compose exec -T "$parallel_service" conjurctl wait --retries 180
7777
done
7878

7979
echo "Create cucumber account..."
8080

8181
for parallel_service in "${parallel_services[@]}"; do
82-
docker-compose exec -T "$parallel_service" conjurctl account create cucumber
82+
docker compose exec -T "$parallel_service" conjurctl account create cucumber
8383
done
8484

8585
# Stage 2: Prepare cucumber environment args
@@ -113,8 +113,8 @@ _run_cucumber_tests() {
113113
done
114114

115115
# Add the cucumber env vars that we always want to send.
116-
# Note: These are args for docker-compose run, and as such the right hand
117-
# sides of the = do NOT require escaped quotes. docker-compose takes the
116+
# Note: These are args for docker compose run, and as such the right hand
117+
# sides of the = do NOT require escaped quotes. docker compose takes the
118118
# entire arg, splits on the =, and uses the rhs as the value,
119119
env_var_flags+=(
120120
-e "CUCUMBER_NETWORK=$(_find_cucumber_network)"
@@ -127,7 +127,7 @@ _run_cucumber_tests() {
127127
done
128128

129129
# If there's no tty (e.g. we're running as a Jenkins job), pass -T to
130-
# docker-compose.
130+
# docker compose.
131131
run_flags=(--no-deps --rm)
132132
if ! tty -s; then
133133
run_flags+=(-T)
@@ -153,7 +153,7 @@ _run_cucumber_tests() {
153153

154154
# Have to add tags in profile for parallel to run properly
155155
# ${cucumber_tags_arg} should overwrite the profile tags in a way for @smoke to work correctly
156-
docker-compose run "${run_flags[@]}" "${env_var_flags[@]}" \
156+
docker compose run "${run_flags[@]}" "${env_var_flags[@]}" \
157157
cucumber -ec "\
158158
/oauth/keycloak/scripts/fetch_certificate &&
159159
bundle exec parallel_cucumber . -n ${PARALLEL_PROCESSES} \
@@ -170,14 +170,14 @@ _run_cucumber_tests() {
170170
# process to write the report. The container is kept alive using an infinite
171171
# sleep in the at_exit hook (see .simplecov).
172172
for parallel_service in "${parallel_services[@]}"; do
173-
docker-compose exec -T "$parallel_service" bash -c "pkill -f 'puma 5'"
173+
docker compose exec -T "$parallel_service" bash -c "pkill -f 'puma 5'"
174174
done
175175
}
176176

177177
_get_api_key() {
178178
local service=$1
179179

180-
docker-compose exec -T "${service}" conjurctl \
180+
docker compose exec -T "${service}" conjurctl \
181181
role retrieve-key cucumber:user:admin | tr -d '\r'
182182
}
183183

@@ -187,7 +187,7 @@ _find_cucumber_network() {
187187
# Docker compose conjur/pg services use the same
188188
# network for 1 or more instances so only conjur is passed
189189
# and not other parallel services.
190-
conjur_id=$(docker-compose ps -q conjur)
190+
conjur_id=$(docker compose ps -q conjur)
191191
net=$(docker inspect "${conjur_id}" --format '{{.HostConfig.NetworkMode}}')
192192

193193
docker network inspect "$net" \
@@ -218,7 +218,7 @@ wait_for_cmd() {
218218
_wait_for_pg() {
219219
local svc=$1
220220
local pg_cmd=(psql -U postgres -c "select 1" -d postgres)
221-
local dc_cmd=(docker-compose exec -T "$svc" "${pg_cmd[@]}")
221+
local dc_cmd=(docker compose exec -T "$svc" "${pg_cmd[@]}")
222222

223223
echo "Waiting for pg to come up..."
224224

@@ -237,14 +237,14 @@ is_ldap_up() {
237237
# Note: We need the subshell to group the commands.
238238
(
239239
set -o pipefail
240-
docker-compose exec -T ldap-server bash -c "$ldap_check_cmd" |
240+
docker compose exec -T ldap-server bash -c "$ldap_check_cmd" |
241241
grep '^search: 3$'
242242
) >/dev/null 2>&1
243243
}
244244

245245
start_ldap_server() {
246246
# Start LDAP.
247-
docker-compose up --no-deps --detach ldap-server
247+
docker compose up --no-deps --detach ldap-server
248248

249249
# Wait for up to 90 seconds, since it's slow.
250250
echo "Ensuring that LDAP is up..."

ci/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ finish() {
117117
# TODO: More reliable approach to this.
118118
# Give SimpleCov time to generate reports.
119119
sleep 15
120-
docker-compose down --rmi 'local' --volumes || true
120+
docker compose down --rmi 'local' --volumes || true
121121
}
122122

123123
# main is always called with at least the first arg. When the 2nd arg, the

ci/test_suites/authenticators_jwt/test

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ source "./oauth/keycloak/keycloak_functions.sh"
1010
function main() {
1111
local parallel_services
1212
read -ra parallel_services <<< "$(get_parallel_services 'conjur pg')"
13-
docker-compose up --no-deps -d "${parallel_services[@]}" jwks jwks_py keycloak
13+
docker compose up --no-deps -d "${parallel_services[@]}" jwks jwks_py keycloak
1414

1515
wait_for_keycloak_server
1616
create_keycloak_users
1717
fetch_keycloak_certificate
1818

1919
echo "Configure jwks provider"
20-
docker-compose exec -T jwks "${JWKS_CREATE_CERTIFICATE_SCRIPT_PATH}"
20+
docker compose exec -T jwks "${JWKS_CREATE_CERTIFICATE_SCRIPT_PATH}"
2121

2222
additional_services='jwks jwks_py keycloak'
2323
_run_cucumber_tests authenticators_jwt "$additional_services" \

ci/test_suites/authenticators_oidc/test

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function _hydrate_all_env_args() {
1717
set -o pipefail
1818
# Note: This prints all lines that look like:
1919
# KEYCLOAK_XXX=someval
20-
docker-compose exec -T "${KEYCLOAK_SERVICE_NAME}" printenv | awk '/KEYCLOAK/'
20+
docker compose exec -T "${KEYCLOAK_SERVICE_NAME}" printenv | awk '/KEYCLOAK/'
2121
)
2222

2323
# shellcheck disable=SC2034
@@ -38,7 +38,7 @@ function _hydrate_all_env_args() {
3838
function main() {
3939
local parallel_services
4040
read -ra parallel_services <<< "$(get_parallel_services 'conjur pg')"
41-
docker-compose up --no-deps -d "${parallel_services[@]}" keycloak
41+
docker compose up --no-deps -d "${parallel_services[@]}" keycloak
4242

4343
# We also run an ldap-server container for testing the OIDC & LDAP combined
4444
# use-case. We can't run this use-case in a separate Jenkins step because

ci/test_suites/rspec/test

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ set -e
66
# shellcheck disable=SC1091
77
source "./shared.sh"
88

9-
docker-compose up --no-deps -d pg
9+
docker compose up --no-deps -d pg
1010

1111
_wait_for_pg pg
1212

1313
# Note: The nested, escaped double quotes are needed in case $REPORT_ROOT
1414
# ever changes to a path containing a space.
15-
docker-compose run -T --rm --no-deps cucumber -ec "
15+
docker compose run -T --rm --no-deps cucumber -ec "
1616
bundle exec rake db:migrate
1717
1818
rm -rf \"$REPORT_ROOT/spec/reports\"

ci/test_suites/rspec_audit/test

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ set -e
77
source "./shared.sh"
88

99
# Start Conjur with the audit database
10-
docker-compose up --no-deps -d audit pg
10+
docker compose up --no-deps -d audit pg
1111

1212
_wait_for_pg audit
1313

1414
# Note: The nested double quotes are needed for the first command involving
1515
# $REPORT_ROOT but not for the 2nd one where it appears in the variable
1616
# assignment.
1717
AUDIT_DATABASE_URL=postgres://postgres@audit/postgres \
18-
docker-compose run \
18+
docker compose run \
1919
-T --rm --no-deps --workdir=/src/conjur-server cucumber -ec "
2020
pwd
2121
ci/rspec-audit/migratedb

dev/cli

+5-5
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function add_keycloak_env_vars_to_env_args() {
196196
echo "Extracting keycloak variables & setting as env variables"
197197

198198
local keycloak_env_args=''
199-
keycloak_env_args="$(set -o pipefail; docker-compose exec -T keycloak printenv | grep KEYCLOAK | sed 's/.*/-e &/') \
199+
keycloak_env_args="$(set -o pipefail; docker compose exec -T keycloak printenv | grep KEYCLOAK | sed 's/.*/-e &/') \
200200
-e PROVIDER_URI=https://keycloak:8443/auth/realms/master \
201201
-e PROVIDER_INTERNAL_URI=http://keycloak:8080/auth/realms/master/protocol/openid-connect \
202202
-e PROVIDER_ISSUER=http://keycloak:8080/auth/realms/master \
@@ -234,7 +234,7 @@ while true ; do
234234
case "$1" in
235235
-h | --help ) print_help ; shift ;;
236236
exec )
237-
api_key=$(docker-compose exec -T conjur conjurctl role retrieve-key cucumber:user:admin | tr -d '\r')
237+
api_key=$(docker compose exec -T conjur conjurctl role retrieve-key cucumber:user:admin | tr -d '\r')
238238
env_args="-e CONJUR_AUTHN_API_KEY=$api_key"
239239

240240
case "$2" in
@@ -246,18 +246,18 @@ while true ; do
246246
* ) if [ -z "$2" ]; then shift ; else echo "$2 is not a valid option"; exit 1; fi;;
247247
esac
248248

249-
docker exec $env_args -it --detach-keys 'ctrl-\' $(docker-compose ps -q conjur) bash
249+
docker exec "$env_args" -it --detach-keys "ctrl-\'" "$(docker compose ps -q conjur)" bash
250250
shift ;;
251251
policy )
252252
case "$2" in
253253
load )
254254
account="$3"
255255
policy_file=$4
256-
docker-compose exec conjur conjurctl policy load "$account" "/src/conjur-server/$policy_file"
256+
docker compose exec conjur conjurctl policy load "$account" "/src/conjur-server/$policy_file"
257257
shift 4 ;;
258258
* ) if [ -z "$1" ]; then break; else echo "$1 is not a valid option"; exit 1; fi;;
259259
esac ;;
260-
key ) docker-compose exec -T conjur conjurctl role retrieve-key cucumber:user:admin ; shift ;;
260+
key ) docker compose exec -T conjur conjurctl role retrieve-key cucumber:user:admin ; shift ;;
261261
* ) if [ -z "$1" ]; then break; else echo "$1 is not a valid option"; exit 1; fi;;
262262
esac
263263
done

0 commit comments

Comments
 (0)