소스 검색

Refactored docker compose

Alexander Musikhin 9 달 전
부모
커밋
5f891e5ba6
2개의 변경된 파일50개의 추가작업 그리고 101개의 파일을 삭제
  1. 0 17
      docker-compose.debug.yml
  2. 50 84
      docker-compose.yml

+ 0 - 17
docker-compose.debug.yml

@@ -19,23 +19,6 @@ services:
         environment:
             PHP_IDE_CONFIG: serverName=_
 
-    # Vite Service ----------------------------------------------------------------------------------------------------
-    vite:
-        build:
-            context: .
-            dockerfile: docker/nginx/Dockerfile
-        restart: unless-stopped
-        tty: true
-        command: '/bin/sh -c ''npm run dev'''
-        ports:
-            - 5172:5172
-        volumes:
-            - ./public:/var/frontend
-            - ./:/var/www
-            - ./docker/nginx/conf.d/:/etc/nginx/conf.d/
-        networks:
-            - cpa-network
-
     # Database service -------------------------------------------------------------------------------------------------
     db:
         ports:

+ 50 - 84
docker-compose.yml

@@ -1,5 +1,7 @@
 services:
+    # Main app -laravel
     app:
+        &base-app
         build:
             context: .
             dockerfile: Dockerfile
@@ -15,28 +17,7 @@ services:
             - ./:/var/www
             - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
         networks:
-            - cpa-network
-        depends_on:
-            - app-queue
-
-    app-queue:
-        build:
-            context: .
-            dockerfile: Dockerfile
-            args:
-                - UID=${UID:-1000}
-                - GID=${GID:-1000}
-        restart: unless-stopped
-        tty: true
-        command: php artisan queue:work --tries=3
-        environment:
-            - SERVICE_NAME=app-queue
-            - SERVICE_TAGS=production
-        volumes:
-            - ./:/var/www
-            - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
-        networks:
-            - cpa-network
+            - str-network
         depends_on:
             db:
                 condition: service_healthy
@@ -46,30 +27,30 @@ services:
                 condition: service_started
             websocket:
                 condition: service_started
-#            minio:
-#                condition: service_healthy
+        profiles:
+            - local
+            - prod
 
-    # Vite Service -- DUMMY FOR PRODUCTION MODE ------------------------------------------------------------------------
-    vite:
+    # Laravel`s queue
+    app-queue:
+        <<: *base-app
+        command: php artisan queue:work --tries=3
+        environment:
+            - SERVICE_NAME=app-queue
+    # Laravel`s scheduler
+    app-schedule:
+        <<: *base-app
+        command: php artisan schedule:work
+        environment:
+            SERVICE_NAME: ${COMPOSE_PROJECT_NAME}-schedule
+        hostname: ${COMPOSE_PROJECT_NAME}-schedule
+
+    # Nginx Service ----------------------------------------------------------------------------------------------------
+    webserver:
+        &base-nginx
         build:
             context: .
             dockerfile: docker/nginx/Dockerfile
-        restart: no
-        tty: true
-        command: '/bin/sh -c ''echo Production mode! Exit!'''
-        ports:
-            - 5172:5172
-        volumes:
-            - ./public:/var/frontend
-            - ./:/var/www
-            - ./docker/nginx/conf.d/:/etc/nginx/conf.d/
-        networks:
-            - cpa-network
-    #Nginx Service
-    webserver:
-        build:
-                context: .
-                dockerfile: docker/nginx/Dockerfile
         restart: unless-stopped
         tty: true
         command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
@@ -80,7 +61,20 @@ services:
             - ./:/var/www
             - ./docker/nginx/conf.d/:/etc/nginx/conf.d/
         networks:
-            - cpa-network
+            - str-network
+        profiles:
+            - local
+            - prod
+
+    # Vite Service -----------------------------------------------------------------------------------------------------
+    vite:
+        <<: *base-nginx
+        restart: no
+        command: '/bin/sh -c ''npm run dev'''
+        ports:
+            - 5172:5172
+        profiles:
+            - local
 
     #MySQL Service
     db:
@@ -106,7 +100,10 @@ services:
             - ./docker/mysql/my.cnf:/etc/my.cnf
             - ./docker/database:/var/lib/mysql
         networks:
-            - cpa-network
+            - str-network
+        profiles:
+            - local
+            - prod
 
     websocket:
         build:
@@ -123,10 +120,13 @@ services:
 #        ports:
 #            - ${WS_PORT:-3000}:9000
         networks:
-            - cpa-network
+            - str-network
         depends_on:
             redis:
                 condition: service_healthy
+        profiles:
+            - local
+            - prod
 
     redis:
         image: "redis:alpine"
@@ -135,53 +135,19 @@ services:
         environment:
             - REDIS_REPLICATION_MODE=master
         networks:
-            - cpa-network
+            - str-network
         healthcheck:
             test: redis-cli --raw --pass $$REDIS_PASSWORD incr ping
             start_period: 1s
             interval: 1s
             timeout: 3s
             retries: 255
-#    minio:
-#        image: minio/minio
-#        restart: unless-stopped
-#        volumes:
-#            - minio-data:/data
-#        command: server --console-address 0.0.0.0:39757 /data
-#        environment:
-#            - MINIO_ACCESS_KEY=root
-#            - MINIO_SECRET_KEY=root1234
-#            - CONSOLE_SECURE_TLS_REDIRECT=off
-#        networks:
-#            - cpa-network
-#        healthcheck:
-#            test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
-#            interval: 30s
-#            timeout: 20s
-#            retries: 3
-#
-#    createbuckets:
-#        image: minio/mc
-#        entrypoint: >
-#            /bin/sh -c "
-#            /usr/bin/mc alias set myminio http://minio:9000 root root1234;
-#            /usr/bin/mc mb myminio/storage --region=us-east-1;
-#            /usr/bin/mc anonymous set public myminio/storage;
-#            exit 0;
-#            "
-#        networks:
-#            - cpa-network
-#        depends_on:
-#            minio:
-#                condition: service_healthy
+        profiles:
+            - local
+            - prod
 
 #Docker Networks
 networks:
-    cpa-network:
+    str-network:
         driver: bridge
         name: ${COMPOSE_PROJECT_NAME}-network
-
-#Volumes
-#volumes:
-#    redis:
-#    minio-data: