chore: switch to docker compose setup on e2e workflow

This commit is contained in:
Karol Sójko
2023-02-07 07:35:10 +01:00
parent 5ed9bd243f
commit 4db0aef0ff
4 changed files with 23 additions and 41 deletions

View File

@@ -21,23 +21,6 @@ jobs:
image: standardnotes/snjs
ports:
- 9001:9001
db:
image: mysql:8
env:
MYSQL_DATABASE: standard_notes_db
MYSQL_USER: std_notes_user
MYSQL_PASSWORD: changeme123
MYSQL_ROOT_PASSWORD: changeme123
ports:
- 3306:3306
options: >-
--name "db"
cache:
image: redis:6.0-alpine
ports:
- 6379:6379
options: >-
--name "cache"
mock-event-publisher:
image: standardnotes/mock-event-publisher
ports:
@@ -65,31 +48,18 @@ jobs:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
- name: Build Docker image for E2E testing
run: docker build . -t standardnotes/server:${{ github.sha }}
- name: Create Docker Network
run: docker network create -d bridge e2e-network
- name: Connect external containers to e2e network
run: |
docker network connect --alias mock-event-publisher e2e-network mock-event-publisher
docker network connect --alias db e2e-network db
docker network connect --alias cache e2e-network cache
- name: Create .env file
run: touch .env
- name: Run Server
run: docker run -v $(pwd)/logs:/var/lib/server/logs --network e2e-network -d -p 3123:3000 standardnotes/server:${{ github.sha }}
run: docker compose -f docker-compose.dev.yml up -d
env:
EXPOSED_PORT: 3123
EXPOSED_FILES_SERVER_PORT: 3125
PUBLIC_FILES_SERVER_URL: http://db:3125
DB_HOST: db
DB_PORT: 3306
PUBLIC_FILES_SERVER_URL: http://localhost:3125
DB_USERNAME: std_notes_user
DB_PASSWORD: changeme123
DB_DATABASE: standard_notes_db
REDIS_PORT: 6379
REDIS_HOST: cache
AUTH_SERVER_ACCESS_TOKEN_AGE: 4
AUTH_SERVER_REFRESH_TOKEN_AGE: 10
AUTH_SERVER_EPHEMERAL_SESSION_AGE: 300
@@ -103,5 +73,8 @@ jobs:
- name: Wait for server to start
run: docker/is-available.sh http://localhost:3123 $(pwd)/logs
- name: Connect external containers to self-hosted network
run: docker network connect --alias mock-event-publisher standardnotes_self_hosted mock-event-publisher
- name: Run E2E Test Suite
run: yarn dlx mocha-headless-chrome --timeout 1200000 -f http://localhost:9001/mocha/test.html

View File

@@ -5,8 +5,11 @@ services:
container_name: server-self-hosted
ports:
- ${EXPOSED_PORT}:3000
- ${EXPOSED_FILES_SERVER_PORT}:3104
volumes:
- ./logs:/var/lib/server/logs
networks:
- standardnotes_self_hosted
localstack:
image: localstack/localstack:1.3
@@ -22,6 +25,8 @@ services:
volumes:
- ./docker/localstack_bootstrap.sh:/etc/localstack/init/ready.d/localstack_bootstrap.sh
- /var/run/docker.sock:/var/run/docker.sock
networks:
- standardnotes_self_hosted
db:
image: mysql:8
@@ -38,6 +43,8 @@ services:
volumes:
- ./data/mysql:/var/lib/mysql
- ./data/import:/docker-entrypoint-initdb.d
networks:
- standardnotes_self_hosted
cache:
image: redis:6.0-alpine
@@ -47,3 +54,9 @@ services:
expose:
- 6379
restart: unless-stopped
networks:
- standardnotes_self_hosted
networks:
standardnotes_self_hosted:
name: standardnotes_self_hosted

View File

@@ -16,11 +16,7 @@ if [ -z "$AUTH_SERVER_PORT" ]; then
export AUTH_SERVER_PORT=3103
fi
if [ -z "$EXPOSED_FILES_SERVER_PORT" ]; then
export FILES_SERVER_PORT=3104
else
export FILES_SERVER_PORT=$EXPOSED_FILES_SERVER_PORT
fi
export FILES_SERVER_PORT=3104
if [ -z "$REVISIONS_SERVER_PORT" ]; then
export REVISIONS_SERVER_PORT=3105
@@ -371,4 +367,4 @@ printenv | grep API_GATEWAY_ | sed 's/API_GATEWAY_//g' > /opt/server/packages/ap
supervisord -c /etc/supervisord.conf
exec "$@"
exec "$@"

View File

@@ -6,7 +6,7 @@ LOGS_PATH="$1"
shift
attempt=0
while [ $attempt -le 180 ]; do
while [ $attempt -le 120 ]; do
attempt=$(( $attempt + 1 ))
echo "# Waiting for all services to be up (attempt: $attempt) ..."
ping_api_gateway_result=`curl -s $WAIT_FOR_URL | grep "Welcome"`