diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 2c6df6dd..fa7e9c4b 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -86,8 +86,9 @@ jobs: - name: Deploy to VM run: | - docker compose --file docker-compose.yml --env-file .env pull - docker compose --file docker-compose.yml --env-file .env up \ + source .env + docker compose --file docker-compose.vm.yml --env-file .env pull + docker compose --file docker-compose.vm.yml --env-file .env up \ --detach --remove-orphans --force-recreate env: DOCKER_HOST: "ssh://${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" diff --git a/docker-compose.vm.yml b/docker-compose.vm.yml new file mode 100644 index 00000000..92eec82e --- /dev/null +++ b/docker-compose.vm.yml @@ -0,0 +1,82 @@ +version: "3" + +services: + backend: + image: naxa/dronetm:${BACKEND_TARGET_OVERRIDE:-backend} + restart: always + depends_on: + - db + - minio + ports: + - ${BACKEND_WEB_APP_PORT:-8000}:8000 + env_file: .env + networks: + - dtm-network + + frontend: + image: naxa/dronetm:${FRONTEND_TARGET_OVERRIDE:-frontend} + depends_on: + - minio + env_file: .env + networks: + - dtm-network + + db: + image: postgis/postgis:14-3.4-alpine + restart: always + volumes: + - ${PROJECT_DIR:-.}/DockerData/dtm_db_data:/var/lib/postgresql/data/ + env_file: .env + networks: + - dtm-network + healthcheck: + test: pg_isready -U ${POSTGRES_USER:-dtm} -d ${POSTGRES_DB:-dtm_db} + start_period: 5s + interval: 10s + timeout: 5s + retries: 3 + + minio: + image: "docker.io/minio/minio:${MINIO_TAG:-RELEASE.2023-10-25T06-33-25Z}" + restart: always + command: server /export --console-address 0.0.0.0:9090 --address 0.0.0.0:9000 + volumes: + - ${PROJECT_DIR:-.}/DockerData/minio_data:/export + environment: + MINIO_ROOT_USER: ${S3_ACCESS_KEY:-dtm_user} + MINIO_ROOT_PASSWORD: ${S3_SECRET_KEY:-somelongpassword} + MINIO_CONSOLE_ADDRESS: ":9090" + ports: + - 9000:9000 + - 9090:9090 + networks: + - dtm-network + + createbuckets: + image: "docker.io/minio/minio:${MINIO_TAG:-RELEASE.2023-10-25T06-33-25Z}" + entrypoint: > + /bin/sh -c " mc config host add minio http://minio:9000 \$S3_ACCESS_KEY \$S3_SECRET_KEY; mc mb minio/\$S3_BUCKET_NAME; mc anonymous set download minio/\$S3_BUCKET_NAME/publicuploads/; exit 0; " + env_file: + - .env + depends_on: + - minio + networks: + - dtm-network + + migrations: + image: naxa/dronetm:${BACKEND_TARGET_OVERRIDE:-backend} + volumes: + - ${PROJECT_DIR:-.}/src/backend:/project/src/backend + depends_on: + - backend + - db + env_file: + - .env + networks: + - dtm-network + entrypoint: ["pdm", "run", "alembic", "upgrade", "head"] + restart: "no" + +networks: + dtm-network: + name: dtm-network diff --git a/docker-compose.yml b/docker-compose.yml index b7235b7c..de96173c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -82,7 +82,6 @@ services: build: context: . dockerfile: src/backend/Dockerfile - container_name: dtm_migrations volumes: - ${PROJECT_DIR:-.}/src/backend:/project/src/backend depends_on: