Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ jobs:
run: docker compose -f docker-compose.prod.yml build

- name: Create network
run: docker network create process_api_net
run: docker network create sepex_net

- name: Run the docker compose stack
run: docker compose -f docker-compose.prod.yml up -d

- name: Create bucket
run: >
docker run
--network process_api_net
--network sepex_net
-e MINIO_ROOT_USER=user
-e MINIO_ROOT_PASSWORD=password
-e STORAGE_BUCKET=sepex-storage
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ https://developer.ogc.org/api/processes/index.html

### Linux using Docker

1. Create docker network `docker network create process_api_net`
1. Create docker network `docker network create sepex_net`

1. Build docker images for example plugins
```sh
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/labstack/gommon/log"
)

const DOCKER_NETWORK = "process_api_net"
const DOCKER_NETWORK = "sepex_net"

type ContainerInfo struct {
Exists bool
Expand Down
18 changes: 7 additions & 11 deletions docker-compose.yml → docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ services:
container_name: api
build:
context: ./api
target: dev
ports:
- '5050:5050'
env_file:
- .env
volumes:
- ./api:/app
- ./.data/api:/.data
- /var/run/docker.sock:/var/run/docker.sock
- ./.data/api:/.data
networks:
- process_api_net
- sepex_net
depends_on:
minio:
condition: service_started
Expand All @@ -32,25 +28,25 @@ services:
volumes:
- ./.data/minio:/data
networks:
- process_api_net
- sepex_net

postgres:
container_name: postgres
image: postgres:17.2-alpine3.20
env_file:
- .env
ports:
- '5432:5432'
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB']
interval: 10s
timeout: 5s
retries: 5
ports:
- '5432:5432'
volumes:
- ./.data/postgres:/var/lib/postgresql/data
networks:
- process_api_net
- sepex_net

networks:
process_api_net:
sepex_net:
external: true
11 changes: 11 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include:
- docker-compose.base.yml

services:
api:
build:
target: dev
ports:
- '5050:5050'
volumes:
- ./api:/app
52 changes: 3 additions & 49 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,9 @@
include:
- docker-compose.base.yml

services:
api:
container_name: api
build:
context: ./api
ports:
- '80:5050'
env_file:
- .env
volumes:
- ./api/plugins:/app/plugins
- ./.data/api:/.data
- /var/run/docker.sock:/var/run/docker.sock
networks:
- process_api_net
depends_on:
minio:
condition: service_started
postgres:
condition: service_healthy

minio:
container_name: minio
image: minio/minio:RELEASE.2024-11-07T00-52-20Z.fips
command: server /data --console-address ":9001"
env_file:
- .env
ports:
- '9000:9000'
- '9001:9001'
volumes:
- ./.data/minio:/data
networks:
- process_api_net

postgres:
container_name: postgres
image: postgres:17.2-alpine3.20
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB']
interval: 10s
timeout: 5s
retries: 5
env_file:
- .env
ports:
- '5432:5432'
volumes:
- ./.data/postgres:/var/lib/postgresql/data
networks:
- process_api_net

networks:
process_api_net:
external: true
101 changes: 0 additions & 101 deletions run_e2e_local.sh

This file was deleted.

89 changes: 89 additions & 0 deletions run_e2e_tests_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
set -euo pipefail

COMPOSE="docker compose -f docker-compose.prod.yml"

cleanup() {
echo "---- Tearing down ----"
$COMPOSE down --volumes --remove-orphans 2>/dev/null || true
if [ -d ".data" ]; then
# cleaning up .data/ with docker to avoid permission issues
docker run --rm -v "$PWD/.data:/cleanup" alpine sh -c "rm -rf /cleanup/*"
fi
}
if [ "${1:-}" != "--no-cleanup" ]; then
trap cleanup EXIT
fi

# --- Check .env exists ---
if [ ! -f ".env" ]; then
echo "ERROR: .env file not found. Copy example.env to .env and configure it."
exit 1
fi

# --- Check if .data exists and is non-empty ---
if [ -d ".data" ] && [ -n "$(ls -A .data 2>/dev/null)" ]; then
echo "WARNING: .data/ directory is not empty. E2E tests will overwrite its contents."
read -rp "Delete .data/ and continue? [y/N] " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
docker run --rm -v "$PWD/.data:/cleanup" alpine sh -c "rm -rf /cleanup/*"
else
echo "Aborted."
exit 1
fi
fi

# --- Build plugin example images (same as GH Actions) ---
( cd plugin-examples && chmod +x build.sh && ./build.sh ) &

# --- Build compose stack ---
$COMPOSE build

# --- Network (ignore error if already exists) ---
docker network create sepex_net >/dev/null 2>&1 || true

# --- Run stack ---
$COMPOSE up -d

# --- Create bucket in minio ---
docker run --rm \
--network sepex_net \
-e MINIO_ROOT_USER=user \
-e MINIO_ROOT_PASSWORD=password \
-e STORAGE_BUCKET=sepex-storage \
--entrypoint /bin/sh \
minio/mc:RELEASE.2023-08-18T21-57-55Z \
-c "mc alias set myminio http://minio:9000 \$MINIO_ROOT_USER \$MINIO_ROOT_PASSWORD && mc mb -p myminio/\${STORAGE_BUCKET} || true"

# --- Wait for API ---
attempts=0
max_attempts=12
until curl -fsS http://localhost:80 >/dev/null 2>&1; do
attempts=$((attempts+1))
if [ "$attempts" -ge "$max_attempts" ]; then
echo "API not ready after $max_attempts attempts"
$COMPOSE logs
exit 1
fi
echo "Waiting for API server... attempt $attempts"
sleep 10
done
echo "API server is ready!"

# --- Run newman tests ---
docker run --rm --network="host" \
-v "$PWD/tests/e2e:/etc/newman" \
postman/newman:5.3.1-alpine \
run tests.postman_collection.json \
--env-var "url=localhost:80" \
--reporters cli \
--bail \
--color on

# --- Logs ---
echo "---- docker compose logs ----"
$COMPOSE logs || true
if [ -f .data/api/logs/api.jsonl ]; then
echo "---- .data/api/logs/api.jsonl ----"
cat .data/api/logs/api.jsonl || true
fi
Loading