瀏覽代碼

chore: switch to docker compose setup on e2e workflow

Karol Sójko 2 年之前
父節點
當前提交
4db0aef0ff
共有 4 個文件被更改,包括 23 次插入41 次删除
  1. 7 34
      .github/workflows/common-e2e.yml
  2. 13 0
      docker-compose.dev.yml
  3. 2 6
      docker/docker-entrypoint.sh
  4. 1 1
      docker/is-available.sh

+ 7 - 34
.github/workflows/common-e2e.yml

@@ -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

+ 13 - 0
docker-compose.yml → docker-compose.dev.yml

@@ -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

+ 2 - 6
docker/docker-entrypoint.sh

@@ -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 "$@"

+ 1 - 1
docker/is-available.sh

@@ -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"`