diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..8020dc47 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "server/scripts/shared"] + path = server/scripts/shared + url = https://github.com/defold/aws-build-tools diff --git a/README.md b/README.md index cc6c1319..9b6aa75b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,11 @@ This describes how to run the build server locally. ### Prerequisites * Make sure you have [Docker](https://www.docker.com) installed and running. +* Clone this repo with the _recurse-submodules_ parameter: + * git clone --recurse-submodules +* If you have already cloned the repo, you can init and fetch the submodule like this: + * git submodule init + * git submodule update ### Build * First, build the Extender Docker image by running: `./server/scripts/build.sh` diff --git a/server/scripts/publish-prod.sh b/server/scripts/publish-prod.sh new file mode 100755 index 00000000..a1038d62 --- /dev/null +++ b/server/scripts/publish-prod.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source ${DIR}/shared/publi.sh + +publish extender prod diff --git a/server/scripts/publish-stage.sh b/server/scripts/publish-stage.sh new file mode 100755 index 00000000..01033478 --- /dev/null +++ b/server/scripts/publish-stage.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source ${DIR}/shared/publi.sh + +publish extender stage diff --git a/server/scripts/publish.sh b/server/scripts/publish.sh deleted file mode 100755 index 6283b557..00000000 --- a/server/scripts/publish.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -set -e - -function check_git_status { - VALUE=$(git ls-files -m) - if [ ! "$VALUE" == "" ]; then - echo "YOU HAVE \033[0;31mUNCOMMITTED CHANGES\033[0m!" - exit 1 - fi -} -check_git_status - - -SRC_REPOSITORY="extender/extender:latest" -VERSION=$(date "+%Y%m%d_%H%M") -DEST_REPOSITORY="378120250811.dkr.ecr.eu-west-1.amazonaws.com/extender:$VERSION" -CLUSTER="prod-eu-west1" -SERVICE_NAME="extender" -TASK_FAMILY="extender" - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Tag image to match destination repository -docker tag "$SRC_REPOSITORY" "$DEST_REPOSITORY" - -# Login Docker to AWS ECR -eval $(aws ecr get-login --no-include-email) - -# Push image -docker push "$DEST_REPOSITORY" - -# Deployment -------------------------------------------------------- - -# Create a new task definition for this build -sed -e "s;%IMAGE%;${DEST_REPOSITORY};g" ${DIR}/task-definition-template.json > ${DIR}/task-definition-template-${VERSION}.json -aws ecs register-task-definition --family ${TASK_FAMILY} --cli-input-json file://${DIR}/task-definition-template-${VERSION}.json -rm ${DIR}/task-definition-template-${VERSION}.json - -# Update the service with the latest revision of the task -aws ecs update-service --cluster ${CLUSTER} --service ${SERVICE_NAME} --task-definition ${TASK_FAMILY} diff --git a/server/scripts/shared b/server/scripts/shared new file mode 160000 index 00000000..e9d93045 --- /dev/null +++ b/server/scripts/shared @@ -0,0 +1 @@ +Subproject commit e9d93045b1d3347d8b07318162fa60c833c93771 diff --git a/server/scripts/task-definition-template.json b/server/scripts/task-definition-template-prod.json similarity index 100% rename from server/scripts/task-definition-template.json rename to server/scripts/task-definition-template-prod.json diff --git a/server/scripts/task-definition-template-stage.json b/server/scripts/task-definition-template-stage.json new file mode 100644 index 00000000..5c27adc3 --- /dev/null +++ b/server/scripts/task-definition-template-stage.json @@ -0,0 +1,32 @@ +{ + "family": "extender", + "containerDefinitions": [ + { + "image": "%IMAGE%", + "name": "extender", + "cpu": 10, + "memory": 2048, + "essential": true, + "portMappings": [ + { + "containerPort": 9000 + } + ], + "environment": [ + { + "name": "SPRING_PROFILES_ACTIVE", + "value": "stage" + } + ], + "logConfiguration": { + "logDriver": "awslogs", + "options": { + "awslogs-group": "stage-logs", + "awslogs-region": "eu-west-1", + "awslogs-stream-prefix": "extender", + "awslogs-datetime-format": "%Y-%m-%d %H:%M:%S" + } + } + } + ] +} diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index e55746f1..27871710 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -4,68 +4,62 @@ server: extender: sdk-location: /var/extender/sdk - sdk-cache-size: 10 # Slightly bigger than production in order to not remove version controlled SDK + # Slightly bigger than production in order to not remove version controlled SDK + sdk-cache-size: 10 build-location: /var/extender/builds server: http: idle-timeout: 600000 data-store: url: "http://localhost:9017" - file-size-threshold: 110000 + file-size-threshold: 110000 -spring.http.multipart.max-file-size: 500mb -spring.http.multipart.max-request-size: 500mb -spring.http.multipart.enabled: false - -# Don't check for templates on startup. -spring.mustache.check-template-location: false +spring: + http: + multipart: + enabled: false + max-file-size: 500mb + max-request-size: 500mb + # Don't check for templates on startup + mustache: + check-template-location: false -# All management endpoints except simple health status are disabled for security reasons. +# All management endpoints except simple health status are disabled for security reasons endpoints: - enabled: false - health: - enabled: true - sensitive: false + enabled: false + health: + enabled: true + sensitive: false # Suppress info-logging from metrics reporting client logging.level.okhttp3.OkHttpClient: WARN management: - health.diskspace.path: / - health.diskspace.threshold: 524288000 #500mb + health: + diskspace: + path: / + threshold: 524288000 #500mb --- spring: - profiles: production - -server: - port: 9000 + profiles: stage extender: - sdk-location: /var/extender/sdk sdk-cache-size: 5 - build-location: /var/extender/builds - server: - http: - idle-timeout: 600000 - data-store: - url: "http://localhost:9017" - file-size-threshold: 110000 -spring.http.multipart.max-file-size: 500mb -spring.http.multipart.max-request-size: 500mb -spring.http.multipart.enabled: false +endpoints: + health: + sensitive: true -# Don't check for templates on startup. -spring.mustache.check-template-location: false +--- -# All management endpoints except simple health status are disabled for security reasons. -endpoints: - enabled: false - health: - enabled: true - sensitive: true +spring: + profiles: production -# Suppress info-logging from metrics reporting client -logging.level.okhttp3.OkHttpClient: WARN +extender: + sdk-cache-size: 5 + +endpoints: + health: + sensitive: true