Skip to content

Commit

Permalink
feat(compose): use docker compose (#143)
Browse files Browse the repository at this point in the history
* feat(compose): use `docker compose` available in docker since 20.10

* docs: update service graph for changes in c0ec093

---------

Co-authored-by: PlaceOS Robot <[email protected]>
  • Loading branch information
viv-4 and PlaceOS Robot authored Sep 27, 2024
1 parent 1e43395 commit fd76312
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ jobs:
name: logs-${{ matrix.os }}-${{ matrix.version }}-${{ github.sha }}
path: .logs/*.log
- name: List service statuses
run: docker-compose ps
run: docker compose ps
- name: Check API is reachable
continue-on-error: true
run: curl -S --retry 10 --tls-max 1 --insecure https://localhost:8443/api/engine/v2
- name: Test raw `docker-compose`
run: docker-compose down
- name: Test raw `docker compose`
run: docker compose down
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

networks:
placeos:
name: placeos
Expand Down Expand Up @@ -114,7 +112,7 @@ services:
# Services

rest-api: # Rest API
image: ${PLACE_REST_API_REGISTRY:-docker.io}/placeos/rest-api:${PLACE_REST_API_TAG:-latest}
image: ${PLACE_REST_API_REGISTRY:-docker.io}/placeos/rest-api:${PLACE_REST_API_TAG:-latest}
restart: always
container_name: rest-api
hostname: api # Retained as nginx upstream is `api`
Expand Down
Binary file modified images/service-graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions placeos
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ hard_reset() (
"Failed to drop Elasticsearch indices."

run_or_abort \
"docker-compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' restart nginx" \
"docker compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' restart nginx" \
"Restarting nginx..." \
"Failed to restart nginx." \
"true"
Expand Down Expand Up @@ -312,7 +312,7 @@ start_environment() (


run_or_abort \
"docker-compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' ${PROFILES} pull --quiet" \
"docker compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' ${PROFILES} pull --quiet" \
"Pulling images..." \
"Failed to pull images."

Expand All @@ -324,7 +324,7 @@ start_environment() (
"Failed to create user entity."

run_or_abort \
"docker-compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' ${PROFILES} up --detach" \
"docker compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' ${PROFILES} up --detach" \
"Bringing up services..." \
"Failed to start services."

Expand Down Expand Up @@ -374,7 +374,7 @@ stop_environment() (
done

run_or_abort \
"docker-compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' down --remove-orphans" \
"docker compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' down --remove-orphans" \
"Tearing down $PLACEOS_PRODUCT" \
"Failed to teardown $PLACEOS_PRODUCT"
)
Expand Down Expand Up @@ -586,7 +586,7 @@ update_environment() (

if [[ $restart_services == "true" ]]; then
run_or_abort \
"docker-compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' restart" \
"docker compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' restart" \
"Restarting services on ${version}..." \
"Failed to restart services"
fi
Expand Down Expand Up @@ -742,7 +742,7 @@ uninstall_environment() (

# Stop environment and remove containers, volumes, and images.
run_or_abort \
"docker-compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' down --volumes --networks --rmi all" \
"docker compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' down --volumes --networks --rmi all" \
"Stopping ${PLACEOS_PRODUCT}..." \
"Failed to stop ${PLACEOS_PRODUCT}"

Expand Down Expand Up @@ -819,7 +819,7 @@ migrate() (
# shellcheck disable=2086
./scripts/run-migration ${clean}
run_or_abort \
"docker-compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' up --detach --remove-orphans" \
"docker compose --env-file='${EMPTY_FILE}' --project-directory='${base_path}' up --detach --remove-orphans" \
"Bringing up services..." \
"Failed to start services."
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ open_url() (

ensure_command 'git'
ensure_command 'docker'
ensure_command 'docker-compose'
ensure_command 'docker compose'

# 2. Clones the repo into `~/.placeos`, or the PLACEOS_HOME environment variable

Expand Down
2 changes: 1 addition & 1 deletion scripts/run-init-container
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ base_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../"
EMPTY_FILE="$(touch /tmp/placeos-empty-env; echo "/tmp/placeos-empty-env")"

COMPOSE_PROJECT_NAME=placeos \
docker-compose \
docker compose \
--env-file="${EMPTY_FILE}" \
--project-directory="$base_path" \
run --rm init start
2 changes: 1 addition & 1 deletion scripts/run-sam-task
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ base_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../"
EMPTY_FILE="$(touch /tmp/placeos-empty-env; echo "/tmp/placeos-empty-env")"

COMPOSE_PROJECT_NAME=placeos \
docker-compose \
docker compose \
--env-file="$EMPTY_FILE" \
--project-directory="$base_path" \
run --rm init task "$@"

0 comments on commit fd76312

Please sign in to comment.