Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOREF: Replace docker-compose with docker compose #2735

Merged
merged 8 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ jobs:
MINIO_SECRET_KEY: minioadmin
MINIO_ADDRESS: http://localhost:9004
run: |
docker-compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up -d db
docker-compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up --exit-code-from db_migrate db_migrate
docker-compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up -d minio
docker-compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up --exit-code-from minio_mc minio_mc
docker compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up -d db
docker compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up --exit-code-from db_migrate db_migrate
docker compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up -d minio
docker compose --project-name easi-server-test -f docker-compose.ci_server_test.yml up --exit-code-from minio_mc minio_mc
./scripts/build_app
./scripts/testsuite
docker-compose --project-name easi-server-test -f docker-compose.ci_server_test.yml down
docker compose --project-name easi-server-test -f docker-compose.ci_server_test.yml down
- name: Upload backend test artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
26 changes: 13 additions & 13 deletions scripts/dev
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def up(frontend_included, *args, debug:false, wait:false)
"COMPOSE_HTTP_TIMEOUT" => "120",
"AIR_CONFIG" =>conf,
}
command = "docker-compose #{"--profile frontend" if frontend_included } up --build"
command = "docker compose #{"--profile frontend" if frontend_included } up --build"

if args.any?
command = "#{command} #{args.join(' ')}"
Expand Down Expand Up @@ -192,12 +192,12 @@ end

desc "Stops all services in the project"
task :down do
sh "docker-compose --profile frontend down"
sh "docker compose --profile frontend down"
end

desc "Restart the specified container"
task restart: :consume_args do |t, args|
yml = `docker-compose --profile frontend config`
yml = `docker compose --profile frontend config`
config = YAML.load(yml)["services"]
services = config.keys.sort

Expand All @@ -206,7 +206,7 @@ task restart: :consume_args do |t, args|
puts "service #{service} not one of defined services: #{services.join(', ')}"
next
end
sh "docker-compose rm -s --force #{service}"
sh "docker compose rm -s --force #{service}"
end

Rake::Task["up"].invoke
Expand All @@ -219,7 +219,7 @@ task :tailscale do
environment = {
"COMPOSE_HTTP_TIMEOUT" => "120"
}
command = "docker-compose --profile frontend -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.tailscale.yml up"
command = "docker compose --profile frontend -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.tailscale.yml up"
sh(environment, command, verbose: true)
end

Expand All @@ -231,7 +231,7 @@ namespace :docker do
end

def each_minio_file(&block)
output = `docker-compose run --entrypoint="mc --no-color --json ls -r local/easi-app-file-uploads" minio_mc`
output = `docker compose run --entrypoint="mc --no-color --json ls -r local/easi-app-file-uploads" minio_mc`
json = "[#{output.gsub(/\}\s*\{/, "},{")}]" # convert sort-of-jsonl into conventional json
files = JSON.parse(json)

Expand All @@ -242,7 +242,7 @@ end

def set_file_tag(key, status)
command = %Q{mc tag set 'local/easi-app-file-uploads/#{key}' 'av-status=#{status}'}
sh %Q{docker-compose run --entrypoint="#{command}" minio_mc}
sh %Q{docker compose run --entrypoint="#{command}" minio_mc}
end

namespace :minio do
Expand Down Expand Up @@ -289,7 +289,7 @@ task :reset => :up do
Rake::Task["db:seed"].invoke

# The backend may have lost its database connection
sh("docker-compose restart easi", verbose: true)
sh("docker compose restart easi", verbose: true)
end

namespace :hosts do
Expand Down Expand Up @@ -320,15 +320,15 @@ end
namespace :db do
desc "Runs database migrations and wait for them to complete"
task :migrate do
sh "docker-compose start db_migrate"
sh "docker compose start db_migrate"
loop do
sleep 0.5
status = `docker-compose ps -a | grep "db_migrate-1"`
status = `docker compose ps -a | grep "db_migrate-1"`
match = /Exited \((\d+)\)/.match(status)
if match
unless match[1] == "0"
puts "\n\n🚨 Migration failed! 🚨 Displaying logs from that container:\n\n"
sh("docker-compose logs db_migrate")
sh("docker compose logs db_migrate")
exit(1)
end
break
Expand All @@ -338,7 +338,7 @@ namespace :db do

desc "Destroys the database container and recreates it"
task :recreate do
sh "docker-compose kill db && docker-compose rm -fv db && docker-compose up -d db"
sh "docker compose kill db && docker compose rm -fv db && docker compose up -d db"
end

desc "Load development dataset"
Expand Down Expand Up @@ -394,7 +394,7 @@ namespace :db do

# Delete all files from Minio
puts "Cleaning Minio file storage..."
`docker-compose run --entrypoint='mc --quiet rm -r --force local/easi-app-file-uploads/' minio_mc > /dev/null 2>&1`
`docker compose run --entrypoint='mc --quiet rm -r --force local/easi-app-file-uploads/' minio_mc > /dev/null 2>&1`
end
end

Expand Down
50 changes: 25 additions & 25 deletions scripts/run-cypress-test-docker
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,55 @@ EASI_CONTAINER="${PROJECT_NAME}"_easi_1

# Running in CI
if [[ -n "${CI+x}" ]]; then
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml pull --quiet db_migrate easi
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml pull --quiet db_migrate easi

docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d db
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up --exit-code-from db_migrate db_migrate
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d minio
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up --exit-code-from minio_mc minio_mc
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up --exit-code-from db_seed db_seed
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d easi easi_client
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d email # MailCatcher - needed for email notifications tests
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d db
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up --exit-code-from db_migrate db_migrate
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d minio
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up --exit-code-from minio_mc minio_mc
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up --exit-code-from db_seed db_seed
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d easi easi_client
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up -d email # MailCatcher - needed for email notifications tests

docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up cypress
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml up cypress

docker container cp "${CYPRESS_CONTAINER}":/cypress/screenshots cypress/ || echo "No cypress screenshots copied"
docker container cp "${CYPRESS_CONTAINER}":/cypress/videos cypress/ || echo "No cypress videos copied"
CYPRESS_EXIT_CODE=$(docker container inspect --format='{{.State.ExitCode}}' "${CYPRESS_CONTAINER}")
docker compose cp cypress:/cypress/screenshots cypress/ || echo "No cypress screenshots copied"
docker compose cp cypress:/cypress/videos cypress/ || echo "No cypress videos copied"
CYPRESS_EXIT_CODE=$(docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_ci.yml ps -aq cypress | xargs docker inspect --format='{{.State.ExitCode}}')
echo "done"
exit "${CYPRESS_EXIT_CODE}"
# Running locally
else
# Clean up any containers started through scripts/dev up
docker-compose --profile frontend down
docker compose --profile frontend down

# Clean up any containers started through this script
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml down
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml down

docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml build --parallel
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml build --parallel

docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d db
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up --exit-code-from db_migrate db_migrate
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up --exit-code-from db_seed db_seed
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d minio
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up --exit-code-from minio_mc minio_mc
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d easi easi_client
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d email # MailCatcher - needed for email notifications tests
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d db
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up --exit-code-from db_migrate db_migrate
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up --exit-code-from db_seed db_seed
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d minio
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up --exit-code-from minio_mc minio_mc
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d easi easi_client
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up -d email # MailCatcher - needed for email notifications tests

EASI_EXIT_CODE=$(docker container inspect --format='{{.State.ExitCode}}' "${EASI_CONTAINER}")

if [[ "${EASI_EXIT_CODE}" -ne 0 ]]; then
echo "Docker container ${EASI_CONTAINER} exited unexpectedly. No tests will be run."
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml logs --tail="all" easi
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml logs --tail="all" easi
exit 1
fi

docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up cypress
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml up cypress

CYPRESS_EXIT_CODE=$(docker container inspect --format='{{.State.ExitCode}}' "${CYPRESS_CONTAINER}")

# Clean up
docker-compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml down
docker compose --project-name "${PROJECT_NAME}" -f docker-compose.yml -f docker-compose.cypress_local.yml down

exit "${CYPRESS_EXIT_CODE}"
fi
10 changes: 5 additions & 5 deletions scripts/tag_minio_file
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ if [[ "$tag" != "CLEAN" ]] && [[ "$tag" != "INFECTED" ]] && [[ -n "$tag" ]]; the
exit 1
fi

# Check if docker-compose is installed
if command -v docker-compose &> /dev/null
# Check if docker compose is installed
if command -v docker compose &> /dev/null
then
# docker-compose exists, so we're running on the host machine instead of in a container (presumably on a local machine, not CI),
# docker compose exists, so we're running on the host machine instead of in a container (presumably on a local machine, not CI),
# so use the existing minio_mc service
docker-compose run --entrypoint="mc tag set local$bucket_and_file av-status=$tag" minio_mc
docker compose run --entrypoint="mc tag set local$bucket_and_file av-status=$tag" minio_mc
else
# docker-compose isn't installed, so we're running inside the Cypress container,
# docker compose isn't installed, so we're running inside the Cypress container,
# so use the mc binary (installed in Dockerfile.cypress)
/mc tag set "local$bucket_and_file" "av-status=$tag"
fi