diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ba252dde --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ + +# This worklflow will perform following actions when the code is pushed to development branch: +# - Build the latest docker image in development. +# - Push the latest docker image to Google Artifact Registry-Dev. +# - Rollout the latest image in GKE. +# +# Maintainers: +# - name: Chandu Nainala +# - email: chandu.nainala@uni-jena.de + +name : Build and Deploy to Dev + +on: + push: + branches: [development] + +env: + PROJECT_ID: ${{ secrets.GKE_PROJECT }} + REPOSITORY_NAME: coconut + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + APP_IMAGE: coconut-app + REPOSITORY_NAMESPACE: nfdi4chem + +jobs: + setup-build-publish-deploy-dev: + name: Build & deploy to development + runs-on: ubuntu-latest + environment: + name: Dev + steps: + # Checkout code + - name: Checkout + uses: actions/checkout@v4 + + # Login to Docker + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ env.DOCKER_HUB_USERNAME }} + password: ${{ env.DOCKER_HUB_PASSWORD }} + + # Build and push the app Docker image + - name: Build and push App Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./FrankenPHP.Dockerfile + push: true + build-args: | + RELEASE_VERSION=latest + COMPOSER_AUTH=${{ secrets.COMPOSER_AUTH }} + tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml deleted file mode 100644 index 567bcabb..00000000 --- a/.github/workflows/dev-build.yml +++ /dev/null @@ -1,97 +0,0 @@ - -# This worklflow will perform following actions when the code is pushed to development branch: -# - Build the latest docker image in development. -# - Push the latest docker image to Google Artifact Registry-Dev. -# - Rollout the latest image in GKE. -# -# Maintainers: -# - name: Nisha Sharma -# - email: nisha.sharma@uni-jena.de - -name : Build and Deploy to Dev - -on: - push: - branches: [development] - -env: - PROJECT_ID: ${{ secrets.GKE_PROJECT }} - DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} - DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} - GKE_CLUSTER: autopilot-cluster-coconut - GKE_ZONE: europe-west3 - DEPLOYMENT_NAME: coconut-coconut-app - WORKER_DEPLOYMENT_NAME: coconut-worker - REPOSITORY_NAME: coconut - APP_IMAGE: coconut-app - NGINX_IMAGE: coconut-nginx - SCHEDULER_DEPLOYMENT_NAME: coconut-scheduler - REPOSITORY_NAMESPACE: nfdi4chem - -jobs: - setup-build-publish-deploy-dev: - name: Build & deploy to development - runs-on: ubuntu-latest - environment: - name: Dev - steps: - # Checkout code - - name: Checkout - uses: actions/checkout@v4 - - # Authenticate Github Actions to gcloud. - - name: Authenticate GitHub Actions - uses: 'google-github-actions/auth@v2' - with: - credentials_json: '${{ secrets.GKE_SA_KEY }}' - - # Setup gcloud CLI - - name: Setup gcloud CLI - uses: google-github-actions/setup-gcloud@v2 - - # Get the GKE credentials - - name: Get GKE credentials - uses: google-github-actions/get-gke-credentials@v2 - with: - cluster_name: ${{ env.GKE_CLUSTER }} - location: ${{ env.GKE_ZONE }} - - # Login to Docker - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ env.DOCKER_HUB_USERNAME }} - password: ${{ env.DOCKER_HUB_PASSWORD }} - - # Build and push the app Docker image - - name: Build and push App Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: ./resources/ops/docker/app/app.dockerfile - push: true - build-args: | - RELEASE_VERSION=dev-app-latest - COMPOSER_AUTH=${{ secrets.COMPOSER_AUTH }} - tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-app-latest - - # Build and push the nginx Docker image - - name: Build and push Nginx Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: ./resources/ops/docker/nginx/nginx.dockerfile - push: true - build-args: | - RELEASE_VERSION=dev-nginx-latest - COMPOSER_AUTH=${{ secrets.COMPOSER_AUTH }} - tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-nginx-latest - - # Deploy the latest Docker image to the GKE cluster - - name: Deploy - run: |- - kubectl rollout restart deployment/$DEPLOYMENT_NAME - kubectl rollout restart deployment/$WORKER_DEPLOYMENT_NAME - kubectl rollout restart deployment/$SCHEDULER_DEPLOYMENT_NAME - kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s - kubectl get services -o wide diff --git a/FrankenPHP.Dockerfile b/FrankenPHP.Dockerfile index c076066d..81f6e9b8 100644 --- a/FrankenPHP.Dockerfile +++ b/FrankenPHP.Dockerfile @@ -1,4 +1,3 @@ -# Accepted values: 8.3 - 8.2 ARG PHP_VERSION=8.3 ARG FRANKENPHP_VERSION=latest diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 8599835c..e787411c 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -14,12 +14,13 @@ services: depends_on: - pgsql - redis + - cm worker: build: context: . dockerfile: ./FrankenPHP.Dockerfile image: coconut-8.3/app - container_name: coconut_app_worker + container_name: coconut_worker env_file: - .env networks: @@ -28,6 +29,7 @@ services: - app - pgsql - redis + - cm environment: WITH_SCHEDULER: true WITH_HORIZON: true @@ -71,20 +73,20 @@ services: - ping retries: 3 timeout: 5s - # cm: - # image: "nfdi4chem/cheminformatics-microservice:dev-latest" - # environment: - # HOMEPAGE_URL: "https://docs.api.naturalproducts.net" - # ports: - # - "81:80" - # healthcheck: - # test: ["CMD", "curl", "-f", "http://localhost:81/latest/chem/health"] - # interval: 1m30s - # timeout: 10s - # retries: 20 - # start_period: 60s - # networks: - # - coconut + cm: + image: "nfdi4chem/cheminformatics-microservice:latest-lite" + environment: + HOMEPAGE_URL: "https://docs.api.naturalproducts.net" + ports: + - '${APP_PORT:-8001}:80' + healthcheck: + test: ["CMD", "curl", "-f", "http://cm:80/latest/chem/health"] + interval: 1m30s + timeout: 10s + retries: 20 + start_period: 60s + networks: + - coconut networks: coconut: driver: bridge