diff --git a/.github/workflows/on-pull_request-opened-synchronize-reopened.yml b/.github/workflows/on-pull_request-opened-synchronize-reopened.yml deleted file mode 100644 index a2d509b..0000000 --- a/.github/workflows/on-pull_request-opened-synchronize-reopened.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: pull_request-opened-synchronize-reopened-event - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - job: - runs-on: ubuntu-latest - - steps: - - name: Check out github-actions repo - uses: actions/checkout@v4 - with: - repository: aerius/github-actions - path: aerius-github-actions - ref: v1.1 - - - uses: aerius/github-actions/events/pull_request-event-action@v1.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - uses: aerius/github-actions/extras/docker-build-action@v1.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCKER_IMAGE_NAME: ${{ github.event.repository.name }} - DOCKERFILE_LOCATION: docker/service/Dockerfile diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 7dd8e83..7c80dd9 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -21,11 +21,3 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - - - uses: aerius/github-actions/extras/docker-build-or-publish-based-on-maven-project-version-action@v1.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCKER_REGISTRY_USERNAME: ${{ secrets.NEXUS_USERNAME }} - DOCKER_REGISTRY_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - DOCKER_IMAGE_NAME: ${{ github.event.repository.name }} - DOCKERFILE_LOCATION: docker/service/Dockerfile diff --git a/.github/workflows/on-release-published.yml b/.github/workflows/on-release-published.yml index f944477..583389a 100644 --- a/.github/workflows/on-release-published.yml +++ b/.github/workflows/on-release-published.yml @@ -22,11 +22,3 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - - - uses: aerius/github-actions/extras/docker-publish-action@v1.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCKER_REGISTRY_USERNAME: ${{ secrets.NEXUS_USERNAME }} - DOCKER_REGISTRY_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - DOCKER_IMAGE_NAME: ${{ github.event.repository.name }} - DOCKERFILE_LOCATION: docker/service/Dockerfile diff --git a/Jenkinsfile-OTA b/Jenkinsfile-OTA index 431bd62..343ff70 100644 --- a/Jenkinsfile-OTA +++ b/Jenkinsfile-OTA @@ -16,6 +16,8 @@ pipeline { AERIUS_REGISTRY_URL = "${env.AERIUS_REGISTRY_HOSTNAME}/${env.AERIUS_REGISTRY_PATH}/" AERIUS_IMAGE_TAG = sh(script: "${CICD_SCRIPTS_DIR}/docker/get_image_tag.sh", returnStdout: true) + SERVICE_THEME = "${env.SERVICE_THEME ?: 'NL'}" + } stages { @@ -57,7 +59,7 @@ pipeline { environment { DEPLOY_OTA_ENVIRONMENT_CICD_URL = credentials('DEPLOY_OTA_ENVIRONMENT_CICD_URL') DEPLOY_OTA_ENVIRONMENT_CICD_LOGIN = credentials('DEPLOY_OTA_ENVIRONMENT_CICD_LOGIN') - FLAGS = "${env.JOB_SPECIFIC_FLAGS ?: ''}" + FLAGS = "DISABLE_COGNITO, ${env.JOB_SPECIFIC_FLAGS ?: ''}" CICD_JOB_MESSAGES = sh(script: """${CICD_SCRIPTS_DIR}/job/add_job_duration.sh build "${currentBuild.durationString}" """, returnStdout: true) } diff --git a/docker/service/Dockerfile b/docker/common/service/Dockerfile similarity index 100% rename from docker/service/Dockerfile rename to docker/common/service/Dockerfile diff --git a/docker/copy_dependencies_common.sh b/docker/copy_dependencies_common.sh new file mode 100755 index 0000000..0ab5f63 --- /dev/null +++ b/docker/copy_dependencies_common.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Do not execute this script yourself, make use of the 'copy_dependencies.sh' scripts as present in the profile directories. e.g.: in directory 'nature'. + +SOURCE_DIR='..' +DOCKER_COMMON_DIR='common' + +# Exit on error +set -e + +# Change current directory to directory of script so it can be called from everywhere +SCRIPT_PATH=$(readlink -f "${0}") +SCRIPT_DIR=$(dirname "${SCRIPT_PATH}") +cd "${SCRIPT_DIR}" + +# include functions +source "${CICD_SCRIPTS_DIR}"/docker/images/v1.0/functions.sh + +# Change current directory to previous one so scripts calling this one can function properly +cd - > /dev/null diff --git a/docker/docker-compose.traefik.yaml b/docker/docker-compose.traefik.yaml deleted file mode 100644 index 9abcd89..0000000 --- a/docker/docker-compose.traefik.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright the State of the Netherlands -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# - -version: "3" - -services: - traefik: - image: traefik:v2.2 - command: - - "--log.level=DEBUG" - - "--api.insecure=true" - - "--providers.docker.endpoint=unix:///var/run/docker.sock" - - "--providers.docker.swarmMode=true" - - "--providers.docker.exposedbydefault=false" - - "--providers.docker.network=web" - - "--entrypoints.web.address=:80" - ports: - - 80:80 -# - 4001:8080 - volumes: - # So that Traefik can listen to the Docker events - - /var/run/docker.sock:/var/run/docker.sock:ro - networks: - - web - - service: - deploy: - labels: - - "traefik.enable=true" - - "traefik.http.routers.search-local-service-data.rule=Host(`localhost`) || Host(`127.0.0.1`)" - - "traefik.http.routers.search-local-service-data.entrypoints=web" - - "traefik.http.services.search-local-service-data.loadbalancer.server.port=8090" - networks: - - web - -networks: - web: - external: true diff --git a/docker/.env b/docker/nl/.env similarity index 100% rename from docker/.env rename to docker/nl/.env diff --git a/docker/nl/copy_dependencies.sh b/docker/nl/copy_dependencies.sh new file mode 100755 index 0000000..12f6ad0 --- /dev/null +++ b/docker/nl/copy_dependencies.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +SOURCE_DIR='../../' +DOCKER_COMMON_DIR='../common' + +# Exit on error +set -e + +# Change current directory to directory of script so it can be called from everywhere +SCRIPT_PATH=$(readlink -f "${0}") +SCRIPT_DIR=$(dirname "${SCRIPT_PATH}") +cd "${SCRIPT_DIR}" + +# include functions +source "${CICD_SCRIPTS_DIR}"/docker/images/v1.0/functions.sh + +# Also copy common dependencies +../copy_dependencies_common.sh "${@}" diff --git a/docker/docker-compose.yaml b/docker/nl/docker-compose.yaml similarity index 84% rename from docker/docker-compose.yaml rename to docker/nl/docker-compose.yaml index 2e5ea84..7d6dd8b 100644 --- a/docker/docker-compose.yaml +++ b/docker/nl/docker-compose.yaml @@ -15,15 +15,15 @@ # along with this program. If not, see http://www.gnu.org/licenses/. # -version: "3" +version: "3.8" services: service: build: - context: . - dockerfile: docker/service/Dockerfile - image: ${REGISTRY_URL}service:${IMAGE_TAG} + context: ../../ + dockerfile: docker/common/service/Dockerfile + image: ${AERIUS_REGISTRY_URL}service:${AERIUS_IMAGE_TAG} restart: unless-stopped environment: - TZ=${TIMEZONE} diff --git a/terraform/application_services/app.hcl b/terraform/application_services/app.hcl index 27b10ec..30c950b 100644 --- a/terraform/application_services/app.hcl +++ b/terraform/application_services/app.hcl @@ -1,30 +1,20 @@ locals { - basicinfra_version = "v1" + basicinfra_version = "v1" + ecr_repo = "028339422996.dkr.ecr.eu-west-1.amazonaws.com" - ecr_repo = "nexus-docker.aerius.nl" - - app_name = "aerius" - app_timezone = "Europe/Amsterdam" + app_timezone = "Europe/Amsterdam" target_groups = { "tg1" = {name = "search", protocol = "HTTP", port = "8090", path = "/", matcher = "200-399"} } listener_rules = { - "rule1" = {tg = "tg1", application_type = "SEARCH", path_pattern = "/*", cognito = true} + "rule1" = {tg = "tg1", application_type = "SEARCH", path_pattern = "/*", cognito = false} } ssm_passwords = {} - ecs_ctr_fes_1_instance_type = "c5.xlarge" + ecs_ctr_fes_1_instance_type = "m5.large" ecs_ctr_fes_1_max_instance_size = "2" - ecs_capacity_providers = { - "01" = {description = "On_demand_capacity", number = "001", asg = "01"} - } - - ecs_autoscaling_group = { - "01" = {description = "On_demand_capacity", number = "001", spot = false} - } - } diff --git a/terraform/application_services/ecs_services/modules.json b/terraform/application_services/ecs_services/modules.json index 042a66c..2d698b8 100644 --- a/terraform/application_services/ecs_services/modules.json +++ b/terraform/application_services/ecs_services/modules.json @@ -1,7 +1,7 @@ [ { "url": "git@github.com:aerius/Cloud-infra-modules.git", - "version": "v1", + "version": "v1.1", "checkout_path": "ecs_services" } ] diff --git a/terraform/application_services/ecs_services/service_configuration/outputs.tf b/terraform/application_services/ecs_services/service_configuration/outputs.tf index 7f843d7..5897dcd 100644 --- a/terraform/application_services/ecs_services/service_configuration/outputs.tf +++ b/terraform/application_services/ecs_services/service_configuration/outputs.tf @@ -2,8 +2,8 @@ output "services" { description = "The services object containing all configuration" value = yamldecode(templatefile("${path.module}/services.yaml.tftpl", { APP_TIMEZONE = var.app_timezone, - APP_VERSION = var.service["type"] == "DEV" ? "latest" : var.app_version, - REGISTRY_URL = var.ecr_repo, + APP_VERSION = var.app_version, + REGISTRY_URL = var.ecr_directory == null ? "${var.ecr_repo}/${lower(var.environment)}" : "${var.ecr_repo}/${var.ecr_directory}", BING_APIKEY = nonsensitive(data.aws_ssm_parameter.bing_apikey_search.value) diff --git a/terraform/application_services/ecs_services/service_configuration/services.yaml.tftpl b/terraform/application_services/ecs_services/service_configuration/services.yaml.tftpl index 81b4f79..2efaab8 100644 --- a/terraform/application_services/ecs_services/service_configuration/services.yaml.tftpl +++ b/terraform/application_services/ecs_services/service_configuration/services.yaml.tftpl @@ -18,8 +18,8 @@ services: service: - image: ${REGISTRY_URL}/search:${APP_VERSION} - cpu: 4096 + image: ${REGISTRY_URL}/service:${APP_VERSION} + cpu: 2048 memory: 7100 desired_count: 1 target_group: tg1 diff --git a/terraform/application_services/ecs_services/service_configuration/vars.tf b/terraform/application_services/ecs_services/service_configuration/vars.tf index 9bc7302..8c3e4d2 100644 --- a/terraform/application_services/ecs_services/service_configuration/vars.tf +++ b/terraform/application_services/ecs_services/service_configuration/vars.tf @@ -21,16 +21,6 @@ variable "environment" { description = "A string for the Environment used in the terragrunt repository directory structure. E.g development, test, apps_shared_service. etc" } -variable "loc" { - type = string - description = "A string containing the region Code e.g LDN" -} - -variable "tf_bucket_key_prefix" { - type = string - description = "A string containing the region Code e.g LDN" -} - #========================== # ECS Service Variables #========================== diff --git a/terraform/env.d/10-application_host_headers.sh b/terraform/env.d/10-application_host_headers.sh new file mode 100755 index 0000000..eca3a59 --- /dev/null +++ b/terraform/env.d/10-application_host_headers.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Crash on error +set -e + +cat << EOF + application_host_headers = { + "SEARCH" = "${DEPLOY_WEBHOST}", + } +EOF