Skip to content

Commit

Permalink
[SDP-1292] Replace usage of docker-compose with docker compose (#383
Browse files Browse the repository at this point in the history
)

### What

Replace usage of `docker-compose` with `docker compose` in the CI workflows and the `*.sh` scripts.

### Why

`docker-compose`, AKA Compose V1, stopped receiving updates on July 2023 and the [Docker official documentation says](https://docs.docker.com/compose/migrate/#what-are-the-differences-between-compose-v1-and-compose-v2) it should be replaced by `docker compose`, AKA Compose V2:

<img width="826" alt="Screenshot 2024-08-02 at 3 32 16 PM" src="https://github.com/user-attachments/assets/6ff7291f-9e7e-423d-b8e9-fcf9a07089d8">

Since the versions of our CI actions were updated by dependabot, our CI jobs that used docker-compose started failing, surfacing the problem now that the latest docker versions stopped supporting docker-compose.
  • Loading branch information
marcelosalloum authored Aug 2, 2024
1 parent f6f7a50 commit eb8e59a
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/anchor_platform_integration_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Run Docker Compose for SDP and Anchor Platform
working-directory: dev
run: docker-compose -f docker-compose-sdp-anchor.yml down && docker-compose -f docker-compose-sdp-anchor.yml up --build -d
run: docker compose -f docker-compose-sdp-anchor.yml down && docker compose -f docker-compose-sdp-anchor.yml up --build -d

- name: Install curl
run: sudo apt-get update && sudo apt-get install -y curl
Expand All @@ -55,4 +55,4 @@ jobs:
- name: Docker logs
if: always()
working-directory: dev
run: docker-compose -f docker-compose-sdp-anchor.yml logs && docker-compose -f docker-compose-sdp-anchor.yml down
run: docker compose -f docker-compose-sdp-anchor.yml logs && docker compose -f docker-compose-sdp-anchor.yml down
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
with:
version: v1.56.2 # this is the golangci-lint version
args: --timeout 5m0s
skip-build-cache: true
skip-pkg-cache: true

- name: Run ./gomod.sh
run: ./gomod.sh
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/e2e_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
e2e:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
platform:
- "Stellar"
Expand All @@ -46,12 +47,12 @@ jobs:

- name: Cleanup data
working-directory: internal/integrationtests/docker
run: docker-compose -f docker-compose-e2e-tests.yml down -v
run: docker compose -f docker-compose-e2e-tests.yml down -v
shell: bash

- name: Run Docker Compose for SDP, Anchor Platform and TSS
working-directory: internal/integrationtests/docker
run: docker-compose -f docker-compose-e2e-tests.yml up --build -V -d
run: docker compose -f docker-compose-e2e-tests.yml up --build -V -d
shell: bash

- name: Install curl
Expand Down Expand Up @@ -98,5 +99,5 @@ jobs:
- name: Docker logs
if: always()
working-directory: internal/integrationtests/docker
run: docker-compose -f docker-compose-e2e-tests.yml logs && docker-compose -f docker-compose-e2e-tests.yml down
run: docker compose -f docker-compose-e2e-tests.yml logs && docker compose -f docker-compose-e2e-tests.yml down
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:

- name: Cleanup data
working-directory: internal/integrationtests/docker
run: docker-compose -f docker-compose-e2e-tests.yml down -v
run: docker compose -f docker-compose-e2e-tests.yml down -v
shell: bash

- name: Run Docker Compose for SDP, Anchor Platform and TSS
working-directory: internal/integrationtests/docker
run: docker-compose -f docker-compose-e2e-tests.yml up --build -V -d
run: docker compose -f docker-compose-e2e-tests.yml up --build -V -d
shell: bash

- name: Install curl
Expand Down Expand Up @@ -140,6 +140,6 @@ jobs:
if: always()
working-directory: internal/integrationtests/docker
run: |
docker-compose -f docker-compose-e2e-tests.yml logs
docker-compose -f docker-compose-e2e-tests.yml down -v
docker compose -f docker-compose-e2e-tests.yml logs
docker compose -f docker-compose-e2e-tests.yml down -v
shell: bash
2 changes: 1 addition & 1 deletion dev/docker-compose-tss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
NETWORK_PASSPHRASE: "Test SDF Network ; September 2015"
HORIZON_URL: "https://horizon-testnet.stellar.org"
NUM_CHANNEL_ACCOUNTS: "3"
MAX_BASE_FEE: "100"
MAX_BASE_FEE: "1000000"
TSS_METRICS_PORT: "9002"
TSS_METRICS_TYPE: "TSS_PROMETHEUS"
DISTRIBUTION_PUBLIC_KEY: ${DISTRIBUTION_PUBLIC_KEY}
Expand Down
14 changes: 7 additions & 7 deletions dev/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ fi

# prepare
echo $DIVIDER
echo "====> 👀 start calling docker-compose -p sdp-multi-tenant down"
echo "====> 👀 start calling docker compose -p sdp-multi-tenant down"
docker ps -aq | xargs docker stop | xargs docker rm
#docker-compose -p sdp-multi-tenant down
docker-compose down
echo "====> ✅ finish calling docker-compose down"
#docker compose -p sdp-multi-tenant down
docker compose down
echo "====> ✅ finish calling docker compose down"

# Run docker compose
echo $DIVIDER
Expand Down Expand Up @@ -67,11 +67,11 @@ fi
echo $DIVIDER
echo "====> 👀calling docker compose up"
export GIT_COMMIT="debug"
docker-compose -p sdp-multi-tenant up -d --build
docker compose -p sdp-multi-tenant up -d --build

# Run docker compose
echo $DIVIDER
echo "====> ✅finish calling docker-compose up"
echo "====> ✅finish calling docker compose up"


# Initialize tenants
Expand Down Expand Up @@ -144,7 +144,7 @@ echo "====> ✅Step 3: finished initialization of tenants"
echo $DIVIDER
# Initialize test_users
echo "====> Step 4: initialize test users..."
docker-compose -p sdp-multi-tenant exec sdp-api ./dev/scripts/add_test_users.sh
docker compose -p sdp-multi-tenant exec sdp-api ./dev/scripts/add_test_users.sh
echo $DIVIDER

echo "🎉🎉🎉🎉 SUCCESS! 🎉🎉🎉🎉"
Expand Down
4 changes: 3 additions & 1 deletion internal/data/disbursement_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var (
// | | |--- Check if the receiver wallet exists.
// | | | |--- If the receiver wallet does not exist, create one.
// | | | |--- If the receiver wallet exists and it's not REGISTERED, retry the invitation SMS.
// | | |--- Delete all payments tied to this disbursement.
// | | |--- Delete all previously existing payments tied to this disbursement.
// | | |--- Create all payments passed in the instructions.
func (di DisbursementInstructionModel) ProcessAll(ctx context.Context, userID string, instructions []*DisbursementInstruction, disbursement *Disbursement, update *DisbursementUpdate, maxNumberOfInstructions int) error {
if len(instructions) > maxNumberOfInstructions {
Expand All @@ -85,6 +85,7 @@ func (di DisbursementInstructionModel) ProcessAll(ctx context.Context, userID st
return fmt.Errorf("error fetching receivers by phone number: %w", err)
}

// Create a map of existing receivers for easy lookup
receiverMap := make(map[string]*Receiver)
for _, receiver := range existingReceivers {
receiverMap[receiver.PhoneNumber] = receiver
Expand All @@ -98,6 +99,7 @@ func (di DisbursementInstructionModel) ProcessAll(ctx context.Context, userID st
}
}

// Create missing receivers
for _, instruction := range instructions {
_, exists := receiverMap[instruction.Phone]
if !exists {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ services:
NETWORK_PASSPHRASE: "Test SDF Network ; September 2015"
HORIZON_URL: "https://horizon-testnet.stellar.org"
NUM_CHANNEL_ACCOUNTS: "1"
MAX_BASE_FEE: "100000"
MAX_BASE_FEE: "1000000"
TSS_METRICS_PORT: "9002"
TSS_METRICS_TYPE: "TSS_PROMETHEUS"
DISTRIBUTION_PUBLIC_KEY: ${DISTRIBUTION_PUBLIC_KEY}
Expand Down
2 changes: 1 addition & 1 deletion internal/integrationtests/scripts/e2e_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ for accountType in "${accountTypes[@]}"; do
# Run docker compose
echo $DIVIDER
echo "====> 👀Step 2: build sdp-api, anchor-platform and tss"
docker-compose -f ../docker/docker-compose-e2e-tests.yml up --build -d
docker compose -f ../docker/docker-compose-e2e-tests.yml up --build -d
wait_for_server "http://localhost:8000/health" 20
echo "====> ✅Step 2: finishing build"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ echo "====> ✅Step 1: finish preparation"
# Run docker compose
echo $DIVIDER
echo "====> 👀Step 2: build sdp-api, anchor-platform and tss"
docker-compose -f ../docker/docker-compose-e2e-tests.yml up --build -d
docker compose -f ../docker/docker-compose-e2e-tests.yml up --build -d
wait_for_server "http://localhost:8000/health" 20
echo "====> ✅Step 2: finishing build"

Expand Down
3 changes: 2 additions & 1 deletion internal/serve/httphandler/disbursement_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"net/http"
"slices"
"time"

"github.com/go-chi/chi/v5"
Expand Down Expand Up @@ -203,7 +204,7 @@ func (d DisbursementHandler) PostDisbursementInstructions(w http.ResponseWriter,
}

// check if disbursement is in draft, ready status
if disbursement.Status != data.DraftDisbursementStatus && disbursement.Status != data.ReadyDisbursementStatus {
if !slices.Contains([]data.DisbursementStatus{data.DraftDisbursementStatus, data.ReadyDisbursementStatus}, disbursement.Status) {
httperror.BadRequest("disbursement is not in draft or ready status", nil, nil).Render(w)
return
}
Expand Down
6 changes: 5 additions & 1 deletion internal/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ func handleHTTP(o ServeOptions) *chi.Mux {
}.ServeHTTP) // This loads the SEP-24 PII registration webpage.

sep24HeaderTokenAuthenticationMiddleware := anchorplatform.SEP24HeaderTokenAuthenticateMiddleware(o.sep24JWTManager, o.NetworkPassphrase, o.tenantManager, o.SingleTenantMode)
r.With(sep24HeaderTokenAuthenticationMiddleware).Post("/otp", httphandler.ReceiverSendOTPHandler{Models: o.Models, SMSMessengerClient: o.SMSMessengerClient, ReCAPTCHAValidator: reCAPTCHAValidator}.ServeHTTP)
r.With(sep24HeaderTokenAuthenticationMiddleware).Post("/otp", httphandler.ReceiverSendOTPHandler{
Models: o.Models,
SMSMessengerClient: o.SMSMessengerClient,
ReCAPTCHAValidator: reCAPTCHAValidator,
}.ServeHTTP)
r.With(sep24HeaderTokenAuthenticationMiddleware).Post("/verification", httphandler.VerifyReceiverRegistrationHandler{
AnchorPlatformAPIService: o.AnchorPlatformAPIService,
Models: o.Models,
Expand Down
4 changes: 2 additions & 2 deletions v1_compatibility/database_migration_compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ echo "====> ✅Step 1: finish cloning SDP v1 (stellar/stellar-relief-backoffice-
# Run docker compose
echo $DIVIDER
echo "====> 👀Step 2: start calling docker compose up"
docker compose down && docker-compose up --abort-on-container-exit
echo "====> ✅Step 2: finish calling docker-compose up"
docker compose down && docker compose up --abort-on-container-exit
echo "====> ✅Step 2: finish calling docker compose up"

echo $DIVIDER
echo "🎉🎉🎉🎉 SUCCESS! 🎉🎉🎉🎉"

0 comments on commit eb8e59a

Please sign in to comment.