Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

CI/CD improvements (combined into single re-usable workflow) (#622)

Rich Turner1eb12a0e1037
diff --git a/.ci_cd/ci_cd.json b/.ci_cd/ci_cd.json
new file mode 100644
index 000000000..f41cef0f3
--- /dev/null
+++ b/.ci_cd/ci_cd.json
@@ -0,0 +1,23 @@
+{
+ "push": {
+ "develop": {
+ "distribute": {
+ "tags": "develop"
+ }
+ },
+ "master": {
+ "distribute": {
+ "tags": "latest"
+ }
+ }
+ },
+ "release": {
+ "distribute": {
+ "tags": "latest,$version"
+ },
+ "deploy": {
+ "managerTag": "latest",
+ "environment": "production"
+ }
+ }
+}
diff --git a/.ci_cd/deploy.sh b/.ci_cd/deploy.sh
new file mode 100644
index 000000000..479183327
--- /dev/null
+++ b/.ci_cd/deploy.sh
@@ -0,0 +1,225 @@
+#!/bin/bash
+
+if [ -f "temp/env" ]; then
+ echo "Loading environment variables: 'temp/env'"
+ set -a
+ . ./temp/env
+ set +x
+fi
+
+if [ -f "ssh.env" ]; then
+ echo "Loading SSH password environment variable: 'ssh.env'"
+ set -a
+ . ./ssh.env
+ set +x
+fi
+
+if [ -z "$HOST" ]; then
+ echo "SSH Host is not set"
+ exit 1
+fi
+
+if [ ! -z "$ENV_COMPOSE_FILE" ]; then
+ if [ -f "profile/$ENVIRONMENT.yml" ]; then
+ cp "profile/$ENVIRONMENT.yml" temp/docker-compose.yml
+ elif [ -f "docker-compose.yml" ]; then
+ cp docker-compose.yml temp/docker-compose.yml
+ fi
+elif [ -f "$ENV_COMPOSE_FILE" ]; then
+ cp "$ENV_COMPOSE_FILE" temp/docker-compose.yml
+else
+ cp docker-compose.yml temp/docker-compose.yml
+fi
+
+if [ ! -f "temp/docker-compose.yml" ]; then
+ echo "Docker compose file missing: 'temp/docker-compose.yml'"
+ exit 1
+fi
+
+sshCommandPrefix="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
+scpCommandPrefix="scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
+
+if [ -f "$SSH_PORT" ]; then
+ sshCommandPrefix="$sshCommandPrefix -p $SSH_PORT"
+ scpCommandPrefix="$scpCommandPrefix -P $SSH_PORT"
+fi
+
+if [ -f "ssh.key" ]; then
+ chmod 400 ssh.key
+ sshCommandPrefix="$sshCommandPrefix -i ssh.key"
+ scpCommandPrefix="$scpCommandPrefix -i ssh.key"
+fi
+
+hostStr="$HOST"
+
+if [ ! -z "$SSH_USER" ]; then
+ hostStr="${SSH_USER}@$hostStr"
+fi
+
+# Get host platform
+PLATFORM=$($sshCommandPrefix $hostStr -- uname -m)
+if [ "$?" != 0 -o -z "$PLATFORM" ]; then
+ echo "Failed to determine host platform"
+ exit 1
+fi
+if [ "$PLATFORM" == "x86_64" ]; then
+ PLATFORM="amd64"
+fi
+PLATFORM="linux/$PLATFORM"
+
+# Create docker image tarballs as required
+if [ "$MANAGER_TAG" != '#ref' ]; then
+ docker manifest inspect openremote/manager:$MANAGER_TAG > /dev/null 2> /dev/null
+ if [ $? != 0 ]; then
+ echo "Specified manager tag does not exist in docker hub"
+ exit 1
+ fi
+else
+ echo "Using commit SHA for manager docker tag: $MANAGER_REF"
+ MANAGER_TAG="$MANAGER_REF"
+ # Export manager docker image for host platform
+ docker build -o type=docker,dest=- --build-arg GIT_REPO=$REPO_NAME --build-arg GIT_COMMIT=$MANAGER_REF --platform $PLATFORM -t openremote/manager:$MANAGER_REF $MANAGER_DOCKER_BUILD_PATH | gzip > temp/manager.tar.gz
+ if [ $? -ne 0 -o ! -f temp/manager.tar.gz ]; then
+ echo "Failed to export manager image with tag: $MANAGER_REF"
+ exit 1
+ fi
+fi
+
+if [ ! -z "$DEPLOYMENT_REF" ]; then
+ # Export deployment docker image for host platform
+ docker build -o type=docker,dest=- --build-arg GIT_REPO=$REPO_NAME --build-arg GIT_COMMIT=$DEPLOYMENT_REF --platform $PLATFORM -t openremote/deployment:$DEPLOYMENT_REF $DEPLOYMENT_DOCKER_BUILD_PATH | gzip > temp/deployment.tar.gz
+ if [ $? -ne 0 -o ! -f temp/deployment.tar.gz ]; then
+ echo "Failed to export deployment image"
+ exit 1
+ fi
+fi
+
+if [ -d ".ci_cd/host_init" ]; then
+ cp -r .ci_cd/host_init temp/
+fi
+
+# Set version variables
+MANAGER_VERSION="$MANAGER_TAG"
+DEPLOYMENT_VERSION="$DEPLOYMENT_REF"
+echo "MANAGER_VERSION=\"$MANAGER_VERSION\"" >> temp/env
+echo "DEPLOYMENT_VERSION=\"$DEPLOYMENT_VERSION\"" >> temp/env
+
+echo "GZipping temp dir"
+tar -zcvf temp.tar.gz temp
+
+echo "Copying temp dir to host"
+$scpCommandPrefix temp.tar.gz ${hostStr}:~
+
+echo "Running deployment on host"
+$sshCommandPrefix ${hostStr} << EOF
+ echo "Removing host temp dir"
+ rm -fr temp
+
+ echo "Extracting temp dir"
+ tar -xvzf temp.tar.gz
+
+ chmod +x -R temp/
+
+ set -a
+ . ./temp/env
+ set +a
+
+ if [ -f "temp/manager.tar.gz" ]; then
+ docker load < temp/manager.tar.gz
+ fi
+
+ if [ -f "temp/deployment.tar.gz" ]; then
+ docker load < temp/deployment.tar.gz
+ fi
+
+ # Run host init
+ if [ "$HOST_INIT_SCRIPT" == 'NONE' -o "$HOST_INIT_SCRIPT" == 'none' ]; then
+ echo "No host init requested"
+ elif [ ! -z "$HOST_INIT_SCRIPT" ]; then
+ if [ ! -f ".ci_cd/host_init/${HOST_INIT_SCRIPT}.sh" ]; then
+ echo "HOST_INIT_SCRIPT (.ci_cd/host_init/${HOST_INIT_SCRIPT}.sh) does not exist"
+ exit 1
+ fi
+ hostInitCmd=".ci_cd/host_init/${HOST_INIT_SCRIPT}.sh"
+ elif [ -f ".ci_cd/host_init/$ENVIRONMENT.sh" ]; then
+ hostInitCmd=".ci_cd/host_init/$ENVIRONMENT.sh"
+ elif [ -f ".ci_cd/host_init/init.sh" ]; then
+ hostInitCmd=".ci_cd/host_init/init.sh"
+ fi
+ if [ ! -z "$hostInitCmd" ]; then
+ echo "Running host init script: '$hostInitCmd'"
+ $hostInitCmd
+ fi
+
+ # MAKE SURE WE HAVE CORRECT KEYCLOAK, PROXY AND POSTGRES IMAGES
+ docker-compose -p or -f temp/docker-compose.yml pull --ignore-pull-failures
+
+ # Attempt docker compose down
+ docker-compose -f temp/docker-compose.yml -p or down
+
+ # Delete postgres volume if CLEAN_INSTALL=true
+ if [ $CLEAN_INSTALL == 'true' ]; then
+ docker volume rm or_postgresql-data
+ fi
+
+ # Delete any deployment volume so we get the latest
+ docker volume rm or_deployment-data
+
+ # Start the stack
+ docker-compose -f temp/docker-compose.yml -p or up -d
+
+ if [ $? != 0 ];then
+ echo "Deployment failed to start the stack"
+ exit 1
+ fi
+
+ echo "Waiting for up to 5mins for standard services to be healthy"
+ count=0
+ ok=false
+ while [ \$ok != 'true' ] && [ \$count -lt 36 ]; do
+ echo \"attempt...\$count\"
+ sleep 5
+ postgresOk=false
+ keycloakOk=false
+ managerOk=false
+ proxyOk=false
+ if [ ! -z "\$(docker ps -aq -f health=healthy -f name=or_postgresql_1)" ]; then
+ postgresOk=true
+ fi
+ if [ ! -z "\$(docker ps -aq -f health=healthy -f name=or_keycloak_1)" ]; then
+ keycloakOk=true
+ fi
+ if [ ! -z "\$(docker ps -aq -f health=healthy -f name=or_manager_1)" ]; then
+ managerOk=true
+ fi
+ if [ ! -z "\$(docker ps -aq -f health=healthy -f name=or_proxy_1)" ]; then
+ proxyOk=true
+ fi
+
+ if [ \$postgresOk == 'true' -a \$keycloakOk == 'true' -a \$managerOk == 'true' -a \$proxyOk == 'true' ]; then
+ ok=true
+ fi
+
+ count=\$((count+1))
+ done
+
+ if [ \$ok != 'true' ]; then
+ echo "Not all containers are healthy"
+ exit 1
+ else
+ docker image prune -f -a
+ docker volume prune -f
+ fi
+EOF
+
+if [ $? -ne 0 ]; then
+ echo "Deployment failed or is unhealthy"
+ exit 1
+fi
+
+echo "Testing manager web server https://$HOST..."
+response=$(curl --output /dev/null --silent --head --write-out "%{http_code}" https://$HOST/manager/)
+if [ $response -ne 200 ]; then
+ echo "Response code = $response"
+ exit 1
+fi
diff --git a/.ci_cd/env/.env b/.ci_cd/env/.env
index c8f23cecd..809650c3b 100644
--- a/.ci_cd/env/.env
+++ b/.ci_cd/env/.env
@@ -1 +1,2 @@
CLEAN_INSTALL=true
+SETUP_WIPE_CLEAN_INSTALL=true
diff --git a/.ci_cd/host_init/init.sh b/.ci_cd/host_init/init.sh
new file mode 100644
index 000000000..ad0db2a9d
--- /dev/null
+++ b/.ci_cd/host_init/init.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+sudo rm /etc/cron.d/openremote
+sudo echo "0 5 * * * docker restart or_manager_1" >> /etc/cron.d/openremote
diff --git a/.ci_cd/mvp/aws-cloudformation.template.yml b/.ci_cd/mvp/aws-cloudformation.template.yml
deleted file mode 100644
index ba3c21345..000000000
--- a/.ci_cd/mvp/aws-cloudformation.template.yml
+++ /dev/null
@@ -1,403 +0,0 @@
----
-AWSTemplateFormatVersion: '2010-09-09'
-Description: 'Template to install OpenRemote 3 stack on Amazon Linux 2'
-Parameters:
- OpenRemotePassword:
- Description: Password for OpenRemote admin login
- Type: String
- Default: secret
- DomainName:
- Description: DNS domain for created stack (clear it is you want the deployment with an insecure SSL certificate)
- Type: String
- Default: developers.openremote.io
- HostName:
- Description: Hostname of the Openremote manager
- Type: String
- Default: demo
- HostedZone:
- Description: Use AWS hosted zone
- Type: String
- Default: true
- AllowedValues:
- - true
- - false
- KeyName:
- Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
- Type: AWS::EC2::KeyPair::KeyName
- Default: openremote
- ConstraintDescription: must be the name of an existing EC2 KeyPair.
- InstanceType:
- Description: EC2 instance type (don't change it unless you know what you are doing)
- Type: String
- # AWS Compute Optimizer reports that this instance type is under-provisioned and advise to use
- # more than double the price instance. However, it works in our test setup.
- Default: t4g.small
- ConstraintDescription: must be a valid EC2 instance type and match AMI processor architecture.
- # https://aws.amazon.com/blogs/compute/query-for-the-latest-amazon-linux-ami-ids-using-aws-systems-manager-parameter-store/
- LatestAmiId:
- Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
- Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-arm64-gp2'
-Conditions:
- DnsRecordCreate: !Equals [!Ref HostedZone, true]
- DomainName: !Not [ !Equals [!Ref DomainName, ""] ]
-Outputs:
- InstanceIP:
- Description: The Instance public IP
- Value: !GetAtt EC2Instance.PublicIp
- PublicUrl:
- Condition: DnsRecordCreate
- Description: OpenRemote Instance URL
- Value: !Join [ ".", [ !Ref HostName, !Ref DomainName ] ]
- UserId:
- Description: SMTP server username
- Value: !Ref AccessKeys
- UserSecret:
- Description: SMTP server password
- Value: !GetAtt AccessKeys.SecretAccessKey
- SmtpServer:
- Value: !Join [ ".", [ "email-smtp", !Ref "AWS::Region", "amazonaws.com"]]
-Resources:
- EmailUser:
- Type: AWS::IAM::User
- Properties:
- Policies:
- - PolicyName: OpenRemoteSendEmail
- PolicyDocument:
- Version: '2012-10-17'
- Statement:
- - Effect: Allow
- Action:
- - ses:SendRawEmail
- Resource:
- - '*'
- AccessKeys:
- Type: AWS::IAM::AccessKey
- Properties:
- UserName: !Ref EmailUser
- DNSRecord:
- Condition: DnsRecordCreate
- Type: AWS::Route53::RecordSet
- Properties:
- HostedZoneName: !Join [ "", [ !Ref DomainName, "." ] ]
- Name: !Join [ ".", [!Ref HostName, !Ref DomainName ] ]
- ResourceRecords:
- - !GetAtt EC2Instance.PublicIp
- TTL: '60'
- Type: A
-# DNSRecord6:
-# Condition: DnsRecordCreate
-# Type: AWS::Route53::RecordSet
-# Properties:
-# HostedZoneName: !Join [ "", [ !Ref DomainName, "." ] ]
-# Name: !Join [ ".", [!Ref HostName, !Ref DomainName ] ]
-# ResourceRecords:
-# - !GetAtt EC2Instance.PublicIp
-# TTL: '60'
-# Type: AAAA
- InstanceRole:
- Type: AWS::IAM::Role
- Properties:
- AssumeRolePolicyDocument:
- Version: '2012-10-17'
- Statement:
- - Effect: Allow
- Principal:
- Service:
- - ec2.amazonaws.com
- Action:
- - sts:AssumeRole
- Path: /
- Policies:
- - PolicyName: InstancePolicy
- PolicyDocument:
- Version: '2012-10-17'
- Statement:
- - Effect: Allow
- Action:
- - logs:CreateLogGroup
- - logs:CreateLogStream
- - logs:PutLogEvents
- - logs:DescribeLogStreams
- - route53:ListHostedZones
- - route53:ChangeResourceRecordSets
- Resource:
- - '*'
- InstanceProfile:
- Type: AWS::IAM::InstanceProfile
- Properties:
- Path: /
- Roles:
- - !Ref 'InstanceRole'
- CloudFormationLogs:
- Type: AWS::Logs::LogGroup
- Properties:
- RetentionInDays: 7
-
- EC2Instance:
- Type: AWS::EC2::Instance
- Metadata:
- AWS::CloudFormation::Init:
- configSets:
- install_all:
- - install_cfn
- - install_logs
- install_cfn:
- packages:
- yum:
- aws-cfn-bootstrap: []
- files:
- /etc/cfn/cfn-hup.conf:
- content: !Sub |
- [main]
- stack=${AWS::StackId}
- region=${AWS::Region}
- interval=1
- mode: '000400'
- owner: root
- group: root
- /etc/cfn/hooks.d/cfn-auto-reloader.conf:
- content: !Sub |
- [cfn-auto-reloader-hook]
- triggers=post.update
- path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
- action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets install_all
- runas=root
- mode: '000400'
- owner: root
- group: root
- services:
- sysvinit:
- cfn-hup:
- enabled: 'true'
- ensureRunning: 'true'
- files:
- - /etc/cfn/cfn-hup.conf
- - /etc/cfn/hooks.d/cfn-auto-reloader.conf
- install_logs:
- # TODO this sends docker logs but not cloud init, why?
- packages:
- yum:
- awslogs: []
- docker: []
- jq: []
- files:
- /etc/awslogs/awslogs.conf:
- content: !Join
- - ''
- - - "[general]\n"
- - "state_file= /var/awslogs/state/agent-state\n"
- - "[/var/log/cloud-init.log]\n"
- - "file = /var/log/cloud-init.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cloud-init.log\n"
- - "datetime_format = \n"
- - "[/var/log/cloud-init-output.log]\n"
- - "file = /var/log/cloud-init-output.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cloud-init-output.log\n"
- - "datetime_format = \n"
- - "[/var/log/cfn-init.log]\n"
- - "file = /var/log/cfn-init.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cfn-init.log\n"
- - "datetime_format = \n"
- - "[/var/log/cfn-hup.log]\n"
- - "file = /var/log/cfn-hup.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cfn-hup.log\n"
- - "datetime_format = \n"
- - "[/var/log/cfn-wire.log]\n"
- - "file = /var/log/cfn-wire.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cfn-wire.log\n"
- - "datetime_format = \n"
- mode: '000444'
- owner: root
- group: root
- /etc/awslogs/awscli.conf:
- content: !Join
- - ''
- - - "[plugins]\n"
- - "cwlogs = cwlogs\n"
- - "[default]\n"
- - 'region = '
- - !Ref 'AWS::Region'
- - "\n"
- mode: '000444'
- owner: root
- group: root
- commands:
- 01_create_state_directory:
- command: mkdir -p /var/awslogs/state
- 02_start_docker:
- command: !Sub |
- systemctl start docker
- services:
- sysvinit:
- awslogs:
- enabled: 'true'
- ensureRunning: 'true'
- files:
- - /etc/awslogs/awslogs.conf
- docker:
- enabled: 'true'
- ensureRunning: 'true'
- CreationPolicy:
- ResourceSignal:
- Timeout: PT7M
- Properties:
- InstanceType:
- Ref: InstanceType
- KeyName:
- Ref: KeyName
- ImageId: !Ref LatestAmiId
- SecurityGroups:
- - Ref: InstanceSecurityGroup
- Ipv6AddressCount: 1
- Tags:
- - Key: "Name"
- Value: !Join [ ".", [ !Ref HostName, !Ref DomainName ] ]
- IamInstanceProfile: !Ref 'InstanceProfile'
- UserData:
- Fn::Base64: !Sub |
- #!/bin/bash -x
- #yum update -y
- #yum install -y aws-cfn-bootstrap
- #rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/arm64/latest/amazon-cloudwatch-agent.rpm
- /opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --configsets install_all --region ${AWS::Region}
- groupadd docker
- gpasswd -a ec2-user docker
- docker swarm init
- curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- # TODO SNMP tools (do we need this?)
- #sudo apt install snmp snmpd snmptt snmptrapd -y
- # Install openremote-cli tool (for e-mail credentials)
- pip3 install -U openremote-cli
- cd /home/ec2-user
- # Create volume for deployment (needed for SWARM due to concurrency in compose-file)
- # docker volume create openremote_deployment-data
- # docker run --rm -v openremote_deployment-data:/deployment openremote/deployment:mvp
- wget https://github.com/openremote/openremote/raw/master/mvp/mvp-docker-compose-awslogs.yml -O docker-compose.yml
- if [ ${HostName} ] && [ ${DomainName} ]
- then
- export DOMAINNAME=${HostName}.${DomainName}
- export EXTERNAL_URL=https://$DOMAINNAME
- elif [ ${DomainName} ]
- then
- export DOMAINNAME=${DomainName}
- export EXTERNAL_URL=https://$DOMAINNAME
- elif [ ${HostName} ]
- then
- export DOMAINNAME=${HostName}
- export EXTERNAL_URL=https://$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
- else
- export DOMAINNAME=localhost
- export EXTERNAL_URL=https://$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
- fi
- openremote-cli -V -t
- echo export EMAIL_PASSWORD=$(openremote-cli configure_aws --secret ${AccessKeys.SecretAccessKey} --quiet) >> access.txt
- echo export EMAIL_USER=${AccessKeys} >> access.txt
- echo export EMAIL_HOST=email-smtp.${AWS::Region}.amazonaws.com >> access.txt
- echo export PASSWORD=${OpenRemotePassword} >> access.txt
- echo export DOMAINNAME=$DOMAINNAME >> access.txt
- echo export EXTERNAL_URL=$EXTERNAL_URL >> access.txt
- echo export AWSLOGS_GROUP=${CloudFormationLogs} >> access.txt
- echo export AWS_REGION=${AWS::Region} >> access.txt
- mkdir ${HostName}
- cd ${HostName}
- wget https://github.com/openremote/openremote/raw/master/mvp/fetch_s3_deploy.sh -O fetch.txt
- cat ../access.txt ./fetch.txt > fetch_s3_deploy.sh
- chmod +x fetch_s3_deploy.sh
- rm fetch.txt
- cd ..
- source access.txt
- # Route53 records
- export IP=`curl http://169.254.169.254/latest/meta-data/public-ipv4`
- export IP6=`curl http://169.254.169.254/latest/meta-data/ipv6`
- export HOSTED_ZONE_ID=`aws route53 list-hosted-zones | jq -r '.HostedZones | .[] | .Id'`
- aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID \
- --change-batch '{ "Changes": [ { "Action": "UPSERT", "ResourceRecordSet": { "Name": "'"$DOMAINNAME"'",
- "Type": "A", "TTL": 60, "ResourceRecords": [ { "Value": "'"$IP"'" } ] } } ] }'
- aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID \
- --change-batch '{ "Changes": [ { "Action": "UPSERT", "ResourceRecordSet": { "Name": "'"$DOMAINNAME"'",
- "Type": "AAAA", "TTL": 60, "ResourceRecords": [ { "Value": "'"$IP6"'" } ] } } ] }'
- # Route53
- docker-compose -p openremote up -d
- /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
-
- InstanceSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: SSH + HTTP + HTTPS + MQTT + ping
- SecurityGroupIngress:
- - IpProtocol: tcp
- FromPort: '22'
- ToPort: '22'
- CidrIp: 0.0.0.0/0
- Description: SSH
- - IpProtocol: tcp
- FromPort: '80'
- ToPort: '80'
- CidrIp: 0.0.0.0/0
- Description: HTTP
- - IpProtocol: tcp
- FromPort: '443'
- ToPort: '443'
- CidrIp: 0.0.0.0/0
- Description: HTTPS
- - IpProtocol: tcp
- FromPort: '8883'
- ToPort: '8883'
- CidrIp: 0.0.0.0/0
- Description: MQTT
- - IpProtocol: udp
- FromPort: '161'
- ToPort: '162'
- CidrIp: 0.0.0.0/0
- Description: SNMP
- - IpProtocol: icmp
- FromPort: '8'
- ToPort: '-1'
- CidrIp: 0.0.0.0/0
- Description: Ping
- - IpProtocol: tcp
- FromPort: '22'
- ToPort: '22'
- CidrIpv6: ::/0
- Description: SSH
- - IpProtocol: tcp
- FromPort: '80'
- ToPort: '80'
- CidrIpv6: ::/0
- Description: HTTP
- - IpProtocol: tcp
- FromPort: '443'
- ToPort: '443'
- CidrIpv6: ::/0
- Description: HTTPS
- - IpProtocol: tcp
- FromPort: '8883'
- ToPort: '8883'
- CidrIpv6: ::/0
- Description: MQTT
- - IpProtocol: udp
- FromPort: '161'
- ToPort: '162'
- CidrIpv6: ::/0
- Description: SNMP
- - IpProtocol: icmpv6
- FromPort: '-1'
- ToPort: '-1'
- CidrIpv6: ::/0
- Description: Ping
diff --git a/.ci_cd/mvp/aws-ubuntu-cloudformation.template.yml b/.ci_cd/mvp/aws-ubuntu-cloudformation.template.yml
deleted file mode 100644
index a04dae587..000000000
--- a/.ci_cd/mvp/aws-ubuntu-cloudformation.template.yml
+++ /dev/null
@@ -1,417 +0,0 @@
----
-AWSTemplateFormatVersion: '2010-09-09'
-Description: 'Template to install OpenRemote 3 stack on AWS environment on ubuntu'
-Parameters:
- OpenRemotePassword:
- Description: Password for OpenRemote admin login
- Type: String
- Default: secret
- DomainName:
- Description: DNS domain for created stack (clear it is you want the deployment with an insecure SSL certificate)
- Type: String
- Default: developers.openremote.io
- HostName:
- Description: Hostname of the Openremote manager
- Type: String
- Default: demo
- HostedZone:
- Description: Use AWS hosted zone
- Type: String
- Default: true
- AllowedValues:
- - true
- - false
- KeyName:
- Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
- Type: AWS::EC2::KeyPair::KeyName
- Default: openremote
- ConstraintDescription: must be the name of an existing EC2 KeyPair.
- InstanceType:
- Description: EC2 instance type (don't change it unless you know what you are doing)
- Type: String
- # AWS Compute Optimizer reports that this instance type is under-provisioned and advise to use
- # more than double the price instance. However, it works in our test setup.
- Default: t4g.small
- ConstraintDescription: must be a valid EC2 instance type.
- InstanceAMI:
- Description: Managed AMI ID for EC2 Instance (don't change it unless you know what you are doing)
- Type : String
- Default: ami-03ec287fa560a6ccc
-Conditions:
- DnsRecordCreate: !Equals [!Ref HostedZone, true]
- DomainName: !Not [ !Equals [!Ref DomainName, ""] ]
-Outputs:
- InstanceIP:
- Description: The Instance public IP
- Value: !GetAtt EC2Instance.PublicIp
- PublicUrl:
- Condition: DnsRecordCreate
- Description: OpenRemote Instance URL
- Value: !Join [ ".", [ !Ref HostName, !Ref DomainName ] ]
- UserId:
- Description: SMTP server username
- Value: !Ref AccessKeys
- UserSecret:
- Description: SMTP server password
- Value: !GetAtt AccessKeys.SecretAccessKey
- SmtpServer:
- Value: !Join [ ".", [ "email-smtp", !Ref "AWS::Region", "amazonaws.com"]]
-Resources:
- EmailUser:
- Type: AWS::IAM::User
- Properties:
- Policies:
- - PolicyName: OpenRemoteSendEmail
- PolicyDocument:
- Version: '2012-10-17'
- Statement:
- - Effect: Allow
- Action:
- - ses:SendRawEmail
- Resource:
- - '*'
- AccessKeys:
- Type: AWS::IAM::AccessKey
- Properties:
- UserName: !Ref EmailUser
- DNSRecord:
- Condition: DnsRecordCreate
- Type: AWS::Route53::RecordSet
- Properties:
- HostedZoneName: !Join [ "", [ !Ref DomainName, "." ] ]
- Name: !Join [ ".", [!Ref HostName, !Ref DomainName ] ]
- ResourceRecords:
- - !GetAtt EC2Instance.PublicIp
- TTL: '60'
- Type: A
-# DNSRecord6:
-# Condition: DnsRecordCreate
-# Type: AWS::Route53::RecordSet
-# Properties:
-# HostedZoneName: !Join [ "", [ !Ref DomainName, "." ] ]
-# Name: !Join [ ".", [!Ref HostName, !Ref DomainName ] ]
-# ResourceRecords:
-# - !GetAtt EC2Instance.PublicIp
-# TTL: '60'
-# Type: AAAA
- LogRole:
- Type: AWS::IAM::Role
- Properties:
- AssumeRolePolicyDocument:
- Version: '2012-10-17'
- Statement:
- - Effect: Allow
- Principal:
- Service:
- - ec2.amazonaws.com
- Action:
- - sts:AssumeRole
- Path: /
- Policies:
- - PolicyName: LogRolePolicy
- PolicyDocument:
- Version: '2012-10-17'
- Statement:
- - Effect: Allow
- Action:
- - logs:CreateLogGroup
- - logs:CreateLogStream
- - logs:PutLogEvents
- - logs:DescribeLogStreams
- Resource:
- - !Join
- - ''
- - - 'arn:aws:'
- - logs:*:*:*
- LogRoleInstanceProfile:
- Type: AWS::IAM::InstanceProfile
- Properties:
- Path: /
- Roles:
- - !Ref 'LogRole'
- CloudFormationLogs:
- Type: AWS::Logs::LogGroup
- Properties:
- RetentionInDays: 7
-
- EC2Instance:
- Type: AWS::EC2::Instance
- Metadata:
- AWS::CloudFormation::Init:
- configSets:
- install_all:
- - install_cfn
- - install_logs
- install_cfn:
- files:
- /etc/cfn/cfn-hup.conf:
- content: !Join
- - ''
- - - "[main]\n"
- - stack=
- - !Ref 'AWS::StackId'
- - "\n"
- - region=
- - !Ref 'AWS::Region'
- - "\n"
- mode: '000400'
- owner: root
- group: root
- /etc/cfn/hooks.d/cfn-auto-reloader.conf:
- content: !Join
- - ''
- - - "[cfn-auto-reloader-hook]\n"
- - "triggers=post.update\n"
- - "path=Resources.WebServerInstance.Metadata.AWS::CloudFormation::Init\n"
- - 'action=/opt/aws/bin/cfn-init -v '
- - ' --stack '
- - !Ref 'AWS::StackName'
- - ' --resource EC2Instance '
- - ' --configsets install_all '
- - ' --region '
- - !Ref 'AWS::Region'
- - "\n"
- - "runas=root\n"
- mode: '000400'
- owner: root
- group: root
- services:
- sysvinit:
- cfn-hup:
- enabled: 'true'
- ensureRunning: 'true'
- files:
- - /etc/cfn/cfn-hup.conf
- - /etc/cfn/hooks.d/cfn-auto-reloader.conf
- install_logs:
- # TODO this won't work. sed is needed on install script. See UserData
- # packages:
- # pip:
- # awslogs: []
- files:
- /etc/awslogs/awslogs.conf:
- content: !Join
- - ''
- - - "[general]\n"
- - "state_file= /var/awslogs/state/agent-state\n"
- - "[/var/log/cloud-init.log]\n"
- - "file = /var/log/cloud-init.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cloud-init.log\n"
- - "datetime_format = \n"
- - "[/var/log/cloud-init-output.log]\n"
- - "file = /var/log/cloud-init-output.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cloud-init-output.log\n"
- - "datetime_format = \n"
- - "[/var/log/cfn-init.log]\n"
- - "file = /var/log/cfn-init.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cfn-init.log\n"
- - "datetime_format = \n"
- - "[/var/log/cfn-hup.log]\n"
- - "file = /var/log/cfn-hup.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cfn-hup.log\n"
- - "datetime_format = \n"
- - "[/var/log/cfn-wire.log]\n"
- - "file = /var/log/cfn-wire.log\n"
- - 'log_group_name = '
- - !Ref 'CloudFormationLogs'
- - "\n"
- - "log_stream_name = {instance_id}/cfn-wire.log\n"
- - "datetime_format = \n"
- mode: '000444'
- owner: root
- group: root
- /etc/awslogs/awscli.conf:
- content: !Join
- - ''
- - - "[plugins]\n"
- - "cwlogs = cwlogs\n"
- - "[default]\n"
- - 'region = '
- - !Ref 'AWS::Region'
- - "\n"
- mode: '000444'
- owner: root
- group: root
- commands:
- '01_create_state_directory':
- command: mkdir -p /var/awslogs/state
- services:
- sysvinit:
- awslogs:
- enabled: 'true'
- ensureRunning: 'true'
- files:
- - /etc/awslogs/awslogs.conf
- Properties:
- InstanceType:
- Ref: InstanceType
- KeyName:
- Ref: KeyName
- ImageId:
- Ref: InstanceAMI
- SecurityGroups:
- - Ref: InstanceSecurityGroup
- Ipv6AddressCount: 1
- Tags:
- - Key: "Name"
- Value: !Join [ ".", [ !Ref HostName, !Ref DomainName ] ]
- IamInstanceProfile: !Ref 'LogRoleInstanceProfile'
- UserData:
- Fn::Base64: !Sub |
- #!/bin/bash
- sudo apt update
- # Install docker newest version
- sudo groupadd docker
- sudo gpasswd -a ubuntu docker
- apt-get update
- apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- echo "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update
- apt-get install docker-ce docker-ce-cli containerd.io -y
- sudo apt install docker-compose -y
- # SNMP tools
- sudo apt install snmp snmpd snmptt snmptrapd -y
- # Install openremote-cli tool
- sudo apt install python3-pip -y
- sudo pip3 install -U openremote-cli
- # CFN tools for CloudWatch
- pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
- cp /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup
- chmod +x /etc/init.d/cfn-hup
- update-rc.d cfn-hup defaults
- service cfn-hup start
- echo cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --configsets install_all --region ${AWS::Region}
- cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --configsets install_all --region ${AWS::Region}
- echo cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}
- cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}
- # end CFN
- # awslogs
- echo AWS Logs
- curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O
- # Bump Python version (TODO AWS)
- sed -i 's/3,6/3,9/g' awslogs-agent-setup.py
- python3 awslogs-agent-setup.py -n -r ${AWS::Region} -c /etc/awslogs/awslogs.conf
- # awslogs
- cd /home/ubuntu
- # Create volume for deployment (needed for SWARM due to concurency in compose-file)
- # docker volume create openremote_deployment-data
- # docker run --rm -v openremote_deployment-data:/deployment openremote/deployment:mvp
- wget https://github.com/openremote/openremote/raw/master/mvp/mvp-docker-compose-awslogs.yml
- docker swarm init
- if [ ${HostName} ] && [ ${DomainName} ]
- then
- export DOMAINNAME=${HostName}.${DomainName}
- export EXTERNAL_URL=https://$DOMAINNAME
- elif [ ${DomainName} ]
- then
- export DOMAINNAME=${DomainName}
- export EXTERNAL_URL=https://$DOMAINNAME
- elif [ ${HostName} ]
- then
- export DOMAINNAME=${HostName}
- export EXTERNAL_URL=https://$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
- else
- export DOMAINNAME=localhost
- export EXTERNAL_URL=https://$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
- fi
- openremote-cli -V -t
- export PASSWORD=${OpenRemotePassword}
- export EMAIL_USER=${AccessKeys}
- export EMAIL_PASSWORD=$(or configure_aws --secret ${AccessKeys.SecretAccessKey} --quiet)
- export EMAIL_HOST=email-smtp.${AWS::Region}.amazonaws.com
- export AWSLOGS_GROUP=${CloudFormationLogs}
- docker-compose -f mvp-docker-compose-awslogs.yml -p openremote up -d
- echo USER=${AccessKeys} > access.txt
- echo SECRET=${AccessKeys.SecretAccessKey} >> access.txt
- echo export EMAIL_PASSWORD=$(or configure_aws --secret ${AccessKeys.SecretAccessKey} --quiet) >> access.txt
- echo export EMAIL_USER=$EMAIL_USER >> access.txt
- echo export EMAIL_HOST=$EMAIL_HOST >> access.txt
- echo export PASSWORD=${OpenRemotePassword} >> access.txt
- echo export DOMAINNAME=$DOMAINNAME >> access.txt
- echo export EXTERNAL_URL=$EXTERNAL_URL >> access.txt
- echo export AWSLOGS_GROUP=${CloudFormationLogs} >> access.txt
- mkdir ${HostName}
- cd ${HostName}
- wget https://github.com/openremote/openremote/raw/master/mvp/fetch_s3_deploy.sh -O fetch.txt
- cat ../access.txt ./fetch.txt > fetch_s3_deploy.sh
- chmod +x fetch_s3_deploy.sh
- rm fetch.txt
-
- InstanceSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: SSH + HTTP + HTTPS + MQTT + ping
- SecurityGroupIngress:
- - IpProtocol: tcp
- FromPort: '22'
- ToPort: '22'
- CidrIp: 0.0.0.0/0
- Description: SSH
- - IpProtocol: tcp
- FromPort: '80'
- ToPort: '80'
- CidrIp: 0.0.0.0/0
- Description: HTTP
- - IpProtocol: tcp
- FromPort: '443'
- ToPort: '443'
- CidrIp: 0.0.0.0/0
- Description: HTTPS
- - IpProtocol: tcp
- FromPort: '8883'
- ToPort: '8883'
- CidrIp: 0.0.0.0/0
- Description: MQTT
- - IpProtocol: udp
- FromPort: '161'
- ToPort: '162'
- CidrIp: 0.0.0.0/0
- Description: SNMP
- - IpProtocol: icmp
- FromPort: '8'
- ToPort: '-1'
- CidrIp: 0.0.0.0/0
- Description: Ping
- - IpProtocol: tcp
- FromPort: '22'
- ToPort: '22'
- CidrIpv6: ::/0
- Description: SSH
- - IpProtocol: tcp
- FromPort: '80'
- ToPort: '80'
- CidrIpv6: ::/0
- Description: HTTP
- - IpProtocol: tcp
- FromPort: '443'
- ToPort: '443'
- CidrIpv6: ::/0
- Description: HTTPS
- - IpProtocol: tcp
- FromPort: '8883'
- ToPort: '8883'
- CidrIpv6: ::/0
- Description: MQTT
- - IpProtocol: udp
- FromPort: '161'
- ToPort: '162'
- CidrIpv6: ::/0
- Description: SNMP
- - IpProtocol: icmpv6
- FromPort: '-1'
- ToPort: '-1'
- CidrIpv6: ::/0
- Description: Ping
diff --git a/.ci_cd/mvp/mvp-docker-compose-awslogs.yml b/.ci_cd/mvp/mvp-docker-compose-awslogs.yml
deleted file mode 100644
index 8d72d7183..000000000
--- a/.ci_cd/mvp/mvp-docker-compose-awslogs.yml
+++ /dev/null
@@ -1,150 +0,0 @@
-# OpenRemote v3
-#
-# Profile that runs the vanilla stack on https://localhost using a self-signed SSL certificate,
-# with username 'admin' and password 'secret'. There is no map data available in the vanilla
-# system so the map tile server will not function. Persistent data is stored in a docker
-# volume called postgresql-data between restarts, simply delete this volume to reset the
-# system to an empty state.
-#
-# Please see profile/deploy.yml for configuration details for each service.
-#
-version: "3.7"
-
-networks:
- public:
- driver: overlay
- driver_opts:
- encrypted: "true"
- attachable: true
- private:
- driver: overlay
- driver_opts:
- encrypted: "true"
- attachable: true
-
-volumes:
- proxy-data:
- postgresql-data:
- deployment-data:
-
-x-app: &awslogs
- logging:
- driver: awslogs
- options:
- awslogs-region: ${AWS_REGION:-eu-west-1}
- awslogs-group: ${AWSLOGS_GROUP:-openremote}
- awslogs-create-group: 'true'
-
-services:
- proxy:
- image: openremote/proxy:${PROXY_VERSION:-2.5.0.1}
- networks:
- - public
- - private
- depends_on:
- - manager
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 3
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:80"]
- ports:
- - "80:80"
- - "443:443"
- - "8883:8883"
- volumes:
- - proxy-data:/deployment
- deploy:
- replicas: 1
- restart_policy:
- delay: 10s
- window: 30s
- update_config:
- failure_action: rollback
- order: start-first
- delay: 30m
- environment:
- DOMAINNAME: ${DOMAINNAME:-localhost}
- LE_EMAIL: admin@${DOMAINNAME}
- <<: *awslogs
-
- manager:
- image: openremote/manager:${MANAGER_VERSION:-latest}
- networks:
- - private
- depends_on:
- - keycloak
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 120
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080"]
- ports:
- # SNMP trap
- - "162:162/udp"
- volumes:
- - deployment-data:/deployment
- deploy:
- replicas: 1
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10s
- environment:
- SETUP_ADMIN_PASSWORD: ${PASSWORD:-secret}
- EXTERNAL_URL: ${EXTERNAL_URL:-https://localhost}
- SETUP_EMAIL_HOST: ${EMAIL_HOST:-email-smtp.eu-west-1.amazonaws.com}
- SETUP_EMAIL_USER: ${EMAIL_USER}
- SETUP_EMAIL_PASSWORD: ${EMAIL_PASSWORD}
- SETUP_EMAIL_PORT: ${SETUP_EMAIL_PORT:-587}
- SETUP_EMAIL_ADMIN: ${SETUP_EMAIL_ADMIN}
- SETUP_EMAIL_FROM: ${SETUP_EMAIL_FROM}
- <<: *awslogs
-
- keycloak:
- image: openremote/keycloak:${KEYCLOAK_VERSION:-16.0.0.0}
- networks:
- - public
- - private
- depends_on:
- - postgresql
- healthcheck:
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/auth"]
- interval: 3s
- timeout: 3s
- start_period: 60s
- retries: 30
- deploy:
- replicas: 1
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10m
- volumes:
- - deployment-data:/deployment
- environment:
- KEYCLOAK_PASSWORD: ${PASSWORD:-secret}
- KEYCLOAK_FRONTEND_URL: ${EXTERNAL_URL:-https://localhost}/auth
- <<: *awslogs
-
- postgresql:
- image: openremote/postgresql:${POSTGRESQL_VERSION:-14.1.0.1}
- networks:
- - private
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 30
- test: ["CMD", "gosu", "postgres", "pg_isready"]
- deploy:
- replicas: 1
- update_config:
- failure_action: rollback
- order: start-first
- delay: 20m
- volumes:
- - postgresql-data:/var/lib/postgresql/data
- <<: *awslogs
diff --git a/.ci_cd/mvp/mvp-docker-compose.yml b/.ci_cd/mvp/mvp-docker-compose.yml
deleted file mode 100644
index 24d6e6098..000000000
--- a/.ci_cd/mvp/mvp-docker-compose.yml
+++ /dev/null
@@ -1,138 +0,0 @@
-# OpenRemote v3
-#
-# Profile that runs the vanilla stack on https://localhost using a self-signed SSL certificate,
-# with username 'admin' and password 'secret'. There is no map data available in the vanilla
-# system so the map tile server will not function. Persistent data is stored in a docker
-# volume called postgresql-data between restarts, simply delete this volume to reset the
-# system to an empty state.
-#
-# Please see profile/deploy.yml for configuration details for each service.
-#
-version: "3.7"
-
-networks:
- public:
- driver: overlay
- driver_opts:
- encrypted: "true"
- attachable: true
- private:
- driver: overlay
- driver_opts:
- encrypted: "true"
- attachable: true
-
-volumes:
- proxy-data:
- postgresql-data:
- deployment-data:
-
-services:
- proxy:
- image: openremote/proxy:${PROXY_VERSION:-2.5.0.1}
- networks:
- - public
- - private
- depends_on:
- - manager
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 3
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:80"]
- ports:
- - "80:80"
- - "443:443"
- - "8883:8883"
- volumes:
- - proxy-data:/deployment
- deploy:
- replicas: 1
- restart_policy:
- delay: 10s
- window: 30s
- update_config:
- failure_action: rollback
- order: start-first
- delay: 30m
- environment:
- DOMAINNAME: ${DOMAINNAME:-localhost}
- LE_EMAIL: admin@${DOMAINNAME}
-
- manager:
- image: openremote/manager:${MANAGER_VERSION:-latest}
- networks:
- - private
- depends_on:
- - keycloak
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 120
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080"]
- ports:
- # SNMP trap
- - "162:162/udp"
- volumes:
- - deployment-data:/deployment
- deploy:
- replicas: 1
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10s
- environment:
- SETUP_ADMIN_PASSWORD: ${PASSWORD:-secret}
- EXTERNAL_URL: ${EXTERNAL_URL:-https://localhost}
- SETUP_EMAIL_HOST: ${EMAIL_HOST:-email-smtp.eu-west-1.amazonaws.com}
- SETUP_EMAIL_USER: ${EMAIL_USER}
- SETUP_EMAIL_PASSWORD: ${EMAIL_PASSWORD}
- SETUP_EMAIL_PORT: ${SETUP_EMAIL_PORT:-587}
- SETUP_EMAIL_FROM_KEYCLOAK: no-reply@${DOMAINNAME}
- SETUP_EMAIL_FROM_DEFAULT: admin@${DOMAINNAME}
-
- keycloak:
- image: openremote/keycloak:${KEYCLOAK_VERSION:-16.0.0.0}
- networks:
- - public
- - private
- depends_on:
- - postgresql
- healthcheck:
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/auth"]
- interval: 3s
- timeout: 3s
- start_period: 60s
- retries: 30
- deploy:
- replicas: 1
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10m
- volumes:
- - deployment-data:/deployment
- environment:
- KEYCLOAK_PASSWORD: ${PASSWORD:-secret}
- KEYCLOAK_FRONTEND_URL: ${EXTERNAL_URL:-https://localhost}/auth
-
- postgresql:
- image: openremote/postgresql:${POSTGRESQL_VERSION:-14.1.0.1}
- networks:
- - private
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 30
- test: ["CMD", "gosu", "postgres", "pg_isready"]
- deploy:
- replicas: 1
- update_config:
- failure_action: rollback
- order: start-first
- delay: 20m
- volumes:
- - postgresql-data:/var/lib/postgresql/data
diff --git a/.ci_cd/swarm/README.md b/.ci_cd/swarm/README.md
deleted file mode 100644
index ff1d490db..000000000
--- a/.ci_cd/swarm/README.md
+++ /dev/null
@@ -1,153 +0,0 @@
-## Introduction
-
-Swarm mode is a built in orchestrator which comes bundled with Docker. Although, currently industry standard
-orchestrator is Kubernetes by Google, using swarm has its merits:
-- it covers 20% features which covers 80% of what people need
-- it is easier to learn therefore less expensive to introduce
-- learning Kubernetes after Swarm is painless
-- Kubernetes is either a full man job or an expensive tool, e.g. [Rancher](https://rancher.com/) costs ~100k/year for
- support
-- Kubernetes being a Google product can be discontinued at any time,
-see [Google graveyard](https://killedbygoogle.com/)
-
-### Swarm commands primer
-```docker stack deploy --compose-file swarm/swarm-docker-compose.yml demo```
-
-```docker stack ls```
-
-```docker stack rm <stack_name>```
-
-```docker service ls```
-
-```docker service ps <service_name>```
-
-```docker service logs <service_name> [--follow]```
-
-Deploy on Kubernetes (works only on builtin Kubernetes in Docker Desktop)
-
-```docker stack deploy --orchestrator kubernetes --compose-file swarm/kube-docker-compose.yml demo```
-
-
-### Swarm advantages:
-- no manual deployments
-- automatic repair in case of node crash
-- possible rollback in case of wrong build
-- secrets management
-- scalable logs
-
-### Swarm disadvantages
-- multi-node swarm is usual more expensive than a single machine. However, the nodes can be lighter than with the
-single machine deployment.
-
-In swarm mode each service shouldn't depend on any other services. The orchestrator can make services go on and off on
-random. Each service should cope with this. Although we have still depends_on entry in the compose file, swarm mode
-does not support condition entry. The depends_on influences only the order of starting containers but not wait till
-container is ready. Therefore, the depending container should resolve the problem itself. An example would be a startup
-code of the manager where it waits for the keycloak.
-
-Compose files v2 are generally used for development and image build, they should not be used in production.
-Compose files v3 are for swarm deployment and some development options are ignored, e.g. like 'build' -
-swarm uses only prebuilt images.
-
-## Persistent data/volumes
-
-We using a trick to populate volumes with data by one container and use them by another one. This generally does not
-work in the swarm mode because we cannot guarantee that both containers would be spin up in the same node.
-
-## Secrets
-
-TODO
-
-## Uninterrupted updates
-
-In the v3 docker-compose file include in the deploy section
-```
- update_config:
- order: start-first
-```
-It results in spinning up a new container when the old one is running, switching over when the new one is ready and
-destroying the old one.
-
-However, it does not work on our current OVH server, does work on AWS though. The reason is, that with this
-configuration and because we are updating all images at once there is not enough resources to deploy double stack
-and hot switch them. We can either use a bigger OVH VM or configure a multi-node swarm. We can also configure that
-only a single service updates it's image at the time, this should be done from begin. However, to do it right we
-should split github repo into separate repos, each one with a single service, i.e. openremote/proxy,
-openremote/postgresql, openremote/keycloak and openremote/manager.
-
-## Deploying swarm on AWS (UI)
-
-- ASW console in Services go to CloudFormation
-- press Create Stack
-- Specify template -> Upload a template file -> Chose file (browse and select swarm/docker-swarm-template.yml from the
-openremote repo)
-- Press next.
-Default openremote swarm has 3 swarm managers nodes and 0 workers. Each node is a t3.small instance (~0.028 EUR/h)
-- Enter stack name, e.g. docker
-- In Swarm Properties select SSH key which you want to use for access. Note, if you don't specify a key here then
-deploying the CloudFormation stack will fail. If you don't have already a key in a given region, go to EC2 console
-and create a new key pair in a region that you want deploy the swarm.
-- press next
-- add any tags if you need
-- press next
-- review stack creation parameters
-- tick 'I acknowledge that AWS CloudFormation might create IAM resources.'
-- Press create stack and wait till stack is complete.
-- After the docker swarm stack is created go to the stack Outputs tab and see the summary. Here you can copy
-DefaultDNSTarget field to use in CNAME DNS record, or ALIAS if you are using AWS Route53 service.
-- Press Managers link which should open EC2 console with 3 swarm manager nodes, here you can see their public IPv4
-addresses, which can be used for ssh access with the private key you've used in the stack creation configuration.
-- TODO letsencrypt does not work with this setup as it requires IPv6 address for identification. The default AWS EC2
-setup is IPv4 only and extra effort should be made to change the template to include IPv6 configuration. However,
-AWS offer a free SSL certification service which should be used instead. This is outside the scope of this document
-though.
-- to deploy openremote stack:
-- copy stack to one of the manager nodes:
-
-```scp swarm/aws-swarm-docker-compose.yml <Manager-Public-IP>:```
-- deploy docker stack:
-
-```ssh docker@<Manager-Public-IP> EXTERNAL_URL=DNS-enrty docker stack deploy --compose-file aws-swarm-docker-compose.yml aws_demo```
-
-you should see something like this:
-```
-Creating network aws_demo_public
-Creating network aws_demo_private
-Creating service aws_demo_keycloak
-Creating service aws_demo_postgresql
-Creating service aws_demo_manager
-```
-You can check deployment with:
-
-```ssh docker@<Manager-Public-IP> docker service ls```
-
-Deployment can take few minutes as images are fetched from the docker hub repository.
-
-After it you should be able to access it http://DNS-entry:8080/manager
-
-If you want automatic images update you can use a project like disrupt https://github.com/BlameButton/disrupt
-
-Example of functional AWS swarm:
-
-```
-> ssh <Manager-Public-IP> docker service ls
-ID NAME MODE REPLICAS IMAGE PORTS
-v5t56il41f3e aws_demo_keycloak replicated 1/1 openremote/keycloak:latest *:8081->8080/tcp
-vinzzbpfgoe1 aws_demo_manager replicated 1/1 openremote/manager-swarm:latest *:8080->8080/tcp
-0a9bg5ssfrxu aws_demo_postgresql replicated 1/1 openremote/postgresql:latest
-slip9ccrin6p disrupt_disrupt replicated 1/1 blamebutton/disrupt:latest
-```
-When region used for the deployment has 3 availability zones (like Ireland or Frankfurt), the the swarm should create
-each node in a different AZ. You should also see in the CloudFormation outputs
-
-ZoneAvailabilityComment This region has at least 3 Availability Zones (AZ). This is ideal to ensure a fully functional
-Swarm in case you lose an AZ.
-
-Note that swarm stack cost money, in the above configuration about 2$ per day, 60$ per month, therefore destroy the
-stack when you don't need it:
-- in the CloudFormation screen select the docker stack
-- in the top right row select Delete button.
-
-
-
-
diff --git a/.ci_cd/swarm/aws-swarm-docker-compose.yml b/.ci_cd/swarm/aws-swarm-docker-compose.yml
deleted file mode 100644
index 5a068c302..000000000
--- a/.ci_cd/swarm/aws-swarm-docker-compose.yml
+++ /dev/null
@@ -1,171 +0,0 @@
-# OpenRemote v3
-#
-# By default running this profile installs the stack in swarm on https://localhost using a
-# self-signed SSL certificate, with username 'admin' and password 'secret'.
-#
-# Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.
-#
-# Start a demo stack in the project root directory with:
-#
-# dosker swarm init
-# docker pull openremote/deployment
-# docker-compose -p demo up -d --no-build deployment
-# docker stack deploy --compose-file docker-compose-swarm.yml demo
-#
-# Stop the stack:
-#
-# docker stack rm demo
-#
-# For full documentation, see profile/deploy.yml
-#
-# For swarm (production) use version 3, for developement use version 2
-version: '3.7'
-
-networks:
- public:
- driver: overlay
- driver_opts:
- encrypted: 'true'
- private:
- driver: overlay
- driver_opts:
- encrypted: 'true'
- attachable: false
-
-# If you enable volume mappings in services, you need this. Otherwise, remove the volumes
-volumes:
- postgresql-data:
-
-services:
-
- manager:
-
- image: openremote/manager-swarm:${DATE_TAG:-latest}
- networks:
- - private
- - public
- depends_on:
- - keycloak
-
- environment:
-
- TZ: Europe/Amsterdam
-
- # If developer mode is enabled, all setup tasks will be executed on application startup.
- # This will clean all data in the database, and then import demo/test data. Some caching and
- # other runtime performance-optimizations will also be disabled.
- DEV_MODE: ${DEV_MODE:-false}
-
- # This switch can wipe your database, this is the factory reset!
- SETUP_WIPE_CLEAN_INSTALL: ${SETUP_WIPE_CLEAN_INSTALL:-true}
- SETUP_ADMIN_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # When you are ready to permanently install your project, replace it with the next lines...
- # SETUP_WIPE_CLEAN_INSTALL: # Allow override on CLI
-
- # Configure SMTP smart host, to send password reset emails etc.
- #SETUP_EMAIL_HOST: smtp-host.demo.tld
- #SETUP_EMAIL_USER: 'smtp-user'
- #SETUP_EMAIL_PASSWORD: 'smtp-password'
- #SETUP_EMAIL_PORT: 25
- #SETUP_EMAIL_TLS: 'true'
- #SETUP_EMAIL_FROM_KEYCLOAK: '[email protected]'
- #SETUP_EMAIL_FROM_DEFAULT: '[email protected]'
-
- # The public URL of the proxy in front of this manager; must match the proxy#DOMAINNAME (unfortunately
- # docker compose doesn't support chaining environment variables at time of writing, hence the need for
- # two environment variables)
- EXTERNAL_URL: ${EXTERNAL_URL:-https://localhost}
-
- # The service-internal host name and port of the identity provider.
- KEYCLOAK_HOST: keycloak
- KEYCLOAK_PORT: 8080
-
- JAVA_OPTS: -Xms400m -Xmx400m
- -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
-
- ports:
- - "8080:8080"
-
- deploy:
- replicas: 1
- # Configure uninterupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
-
- keycloak:
-
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/keycloak:${DATE_TAG:-latest}
- networks:
- - public
- - private
- depends_on:
- - postgresql
-
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # Switch to DEBUG to diagnose Keycloak problems.
- KEYCLOAK_LOGLEVEL: INFO
-
- # When you are ready to permanently install your project, replace it with the next line ...
- # SETUP_ADMIN_PASSWORD: # Allow override on CLI
-
- # CHANGE THIS PASSWORD BEFORE STARTING THE STACK! THIS IS ONLY FOR DEMO!
- KEYCLOAK_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # Custom JVM options (increase heap size if required)
- JAVA_OPTS: -Xms300m -Xmx300m
- -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=200m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
-
- ports:
- - "8081:8080"
-
- deploy:
- replicas: 1
- # Configure uninterupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
-
- # This configuration stores postgresql data in a Docker volume. You manage this volume
- # independently from your stack with with 'docker volume ls', 'docker volume rm', etc.
- # Alternatively, you can store postgresql data in a directory on your host.
- postgresql:
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/postgresql:${DATE_TAG:-latest}
- networks:
- - private
-
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # You can open an SQL console on a running container with:
- # docker exec -it <container ID> psql -U openremote
-
- volumes:
- - postgresql-data:/deployment
-
- deploy:
- replicas: 1
- # Configure uninterupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
diff --git a/.ci_cd/swarm/docker-swarm-template.yml b/.ci_cd/swarm/docker-swarm-template.yml
deleted file mode 100644
index ea976b718..000000000
--- a/.ci_cd/swarm/docker-swarm-template.yml
+++ /dev/null
@@ -1,2081 +0,0 @@
-AWSTemplateFormatVersion: 2010-09-09
-Conditions:
- CloudStorEfsSelected: !Equals
- - !Ref EnableCloudStorEfs
- - 'yes'
- CreateLogResources: !Equals
- - !Ref EnableCloudWatchLogs
- - 'yes'
- EBSOptimized: !Equals
- - !Ref EnableEbsOptimized
- - 'yes'
- EFSEncrypted: !Equals
- - !Ref EncryptEFS
- - 'true'
- EFSSupported: !Equals
- - !FindInMap
- - AWSRegion2AZ
- - !Ref 'AWS::Region'
- - EFSSupport
- - 'yes'
- HasOnly2AZs: !Equals
- - !FindInMap
- - AWSRegion2AZ
- - !Ref 'AWS::Region'
- - NumAZs
- - '2'
- InstallCloudStorEFSPreReqs: !And
- - !Condition EFSSupported
- - !Condition CloudStorEfsSelected
- LambdaSupported: !Equals
- - !FindInMap
- - AWSRegion2AZ
- - !Ref 'AWS::Region'
- - LambdaSupport
- - 'yes'
-Description: Docker CE for AWS 18.09.2-ce (18.09.2-ce-aws1)
-Mappings:
- AWSInstanceType2Arch:
- c3.2xlarge:
- Arch: HVM64
- c3.4xlarge:
- Arch: HVM64
- c3.8xlarge:
- Arch: HVM64
- c3.large:
- Arch: HVM64
- c3.xlarge:
- Arch: HVM64
- c4.2xlarge:
- Arch: HVM64
- c4.4xlarge:
- Arch: HVM64
- c4.8xlarge:
- Arch: HVM64
- c4.large:
- Arch: HVM64
- c4.xlarge:
- Arch: HVM64
- c5.18xlarge:
- Arch: HVM64
- c5.2xlarge:
- Arch: HVM64
- c5.4xlarge:
- Arch: HVM64
- c5.9xlarge:
- Arch: HVM64
- c5.large:
- Arch: HVM64
- c5.xlarge:
- Arch: HVM64
- cc2.8xlarge:
- Arch: HVM64
- cr1.8xlarge:
- Arch: HVM64
- d2.2xlarge:
- Arch: HVM64
- d2.4xlarge:
- Arch: HVM64
- d2.8xlarge:
- Arch: HVM64
- d2.xlarge:
- Arch: HVM64
- g2.2xlarge:
- Arch: HVMG2
- hi1.4xlarge:
- Arch: HVM64
- hs1.8xlarge:
- Arch: HVM64
- i3.16xlarge:
- Arch: HVM64
- i3.2xlarge:
- Arch: HVM64
- i3.4xlarge:
- Arch: HVM64
- i3.8xlarge:
- Arch: HVM64
- i3.large:
- Arch: HVM64
- i3.xlarge:
- Arch: HVM64
- m3.2xlarge:
- Arch: HVM64
- m3.large:
- Arch: HVM64
- m3.medium:
- Arch: HVM64
- m3.xlarge:
- Arch: HVM64
- m4.10xlarge:
- Arch: HVM64
- m4.16xlarge:
- Arch: HVM64
- m4.2xlarge:
- Arch: HVM64
- m4.4xlarge:
- Arch: HVM64
- m4.large:
- Arch: HVM64
- m4.xlarge:
- Arch: HVM64
- m5.12xlarge:
- Arch: HVM64
- m5.24xlarge:
- Arch: HVM64
- m5.2xlarge:
- Arch: HVM64
- m5.4xlarge:
- Arch: HVM64
- m5.large:
- Arch: HVM64
- m5.xlarge:
- Arch: HVM64
- r3.2xlarge:
- Arch: HVM64
- r3.4xlarge:
- Arch: HVM64
- r3.8xlarge:
- Arch: HVM64
- r3.large:
- Arch: HVM64
- r3.xlarge:
- Arch: HVM64
- r4.16xlarge:
- Arch: HVM64
- r4.2xlarge:
- Arch: HVM64
- r4.4xlarge:
- Arch: HVM64
- r4.8xlarge:
- Arch: HVM64
- r4.large:
- Arch: HVM64
- r4.xlarge:
- Arch: HVM64
- t2.2xlarge:
- Arch: HVM64
- t2.large:
- Arch: HVM64
- t2.medium:
- Arch: HVM64
- t2.micro:
- Arch: HVM64
- t2.small:
- Arch: HVM64
- t3.small:
- Arch: HVM64
- t2.xlarge:
- Arch: HVM64
- AWSRegion2AZ:
- ap-northeast-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'yes'
- Name: Tokyo
- NumAZs: '2'
- ap-northeast-2:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'yes'
- Name: Seoul
- NumAZs: '2'
- ap-south-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'yes'
- Name: Mumbai
- NumAZs: '2'
- ap-southeast-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'yes'
- Name: Singapore
- NumAZs: '2'
- ap-southeast-2:
- AZ0: '0'
- AZ1: '1'
- AZ2: '2'
- EFSSupport: 'yes'
- LambdaSupport: 'yes'
- Name: Sydney
- NumAZs: '3'
- ca-central-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'no'
- Name: Central
- NumAZs: '2'
- eu-central-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '2'
- EFSSupport: 'yes'
- LambdaSupport: 'yes'
- Name: Frankfurt
- NumAZs: '3'
- eu-west-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '2'
- EFSSupport: 'yes'
- LambdaSupport: 'yes'
- Name: Ireland
- NumAZs: '3'
- eu-west-2:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'yes'
- Name: London
- NumAZs: '2'
- sa-east-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'no'
- Name: Sao Paulo
- NumAZs: '2'
- us-east-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '2'
- EFSSupport: 'yes'
- LambdaSupport: 'yes'
- Name: N. Virgina
- NumAZs: '4'
- us-east-2:
- AZ0: '0'
- AZ1: '1'
- AZ2: '2'
- EFSSupport: 'yes'
- LambdaSupport: 'yes'
- Name: Ohio
- NumAZs: '3'
- us-gov-west-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'no'
- Name: GovCloud
- NumAZs: '2'
- us-west-1:
- AZ0: '0'
- AZ1: '1'
- AZ2: '0'
- EFSSupport: 'no'
- LambdaSupport: 'yes'
- Name: N. California
- NumAZs: '2'
- us-west-2:
- AZ0: '0'
- AZ1: '1'
- AZ2: '2'
- EFSSupport: 'yes'
- LambdaSupport: 'yes'
- Name: Oregon
- NumAZs: '3'
- AWSRegionArch2AMI:
- ap-northeast-1:
- HVM64: ami-08ced28d734f8dbe5
- HVMG2: NOT_SUPPORTED
- ap-northeast-2:
- HVM64: ami-0ba8823e788887ed7
- HVMG2: NOT_SUPPORTED
- ap-south-1:
- HVM64: ami-0e69e5f6e475143df
- HVMG2: NOT_SUPPORTED
- ap-southeast-1:
- HVM64: ami-09966c7df539b1b38
- HVMG2: NOT_SUPPORTED
- ap-southeast-2:
- HVM64: ami-0fbecffabf7a5216e
- HVMG2: NOT_SUPPORTED
- ca-central-1:
- HVM64: ami-04af8e01d31c3bcd3
- HVMG2: NOT_SUPPORTED
- eu-central-1:
- HVM64: ami-0d8610be366801071
- HVMG2: NOT_SUPPORTED
- eu-west-1:
- HVM64: ami-061dcfa159ed10d52
- HVMG2: NOT_SUPPORTED
- eu-west-2:
- HVM64: ami-0554d180c83974a86
- HVMG2: NOT_SUPPORTED
- sa-east-1:
- HVM64: ami-098d682fe9025058c
- HVMG2: NOT_SUPPORTED
- us-east-1:
- HVM64: ami-0aa9c78728cff2091
- HVMG2: NOT_SUPPORTED
- us-east-2:
- HVM64: ami-0f4fb04ea796afb9a
- HVMG2: NOT_SUPPORTED
- us-west-1:
- HVM64: ami-0affb89b3a31b93dd
- HVMG2: NOT_SUPPORTED
- us-west-2:
- HVM64: ami-0ec4d7d34b9c2e2df
- HVMG2: NOT_SUPPORTED
- DockerForAWS:
- version:
- HasDDC: 'no'
- addOn: base
- channel: stable
- docker: 18.09.2-ce
- forAws: 18.09.2-ce-aws1
- VpcCidrs:
- pubsubnet1:
- cidr: 172.31.0.0/20
- pubsubnet2:
- cidr: 172.31.16.0/20
- pubsubnet3:
- cidr: 172.31.32.0/20
- pubsubnet4:
- cidr: 172.31.48.0/20
- vpc:
- cidr: 172.31.0.0/16
-Metadata:
- 'AWS::CloudFormation::Interface':
- ParameterGroups:
- - Label:
- default: Swarm Size
- Parameters:
- - ManagerSize
- - ClusterSize
- - Label:
- default: Swarm Properties
- Parameters:
- - KeyName
- - EnableSystemPrune
- - EnableCloudWatchLogs
- - EnableCloudStorEfs
- - Label:
- default: Swarm Manager Properties
- Parameters:
- - ManagerInstanceType
- - ManagerDiskSize
- - ManagerDiskType
- - Label:
- default: Swarm Worker Properties
- Parameters:
- - InstanceType
- - WorkerDiskSize
- - WorkerDiskType
- ParameterLabels:
- ClusterSize:
- default: Number of Swarm worker nodes?
- EnableCloudStorEfs:
- default: Create EFS prerequsities for CloudStor?
- EnableCloudWatchLogs:
- default: Use Cloudwatch for container logging?
- EnableEbsOptimized:
- default: Enable EBS I/O optimization?
- EnableSystemPrune:
- default: Enable daily resource cleanup?
- EncryptEFS:
- default: Encrypt EFS objects?
- InstanceType:
- default: Agent worker instance type?
- KeyName:
- default: Which SSH key to use?
- ManagerDiskSize:
- default: Manager ephemeral storage volume size?
- ManagerDiskType:
- default: Manager ephemeral storage volume type
- ManagerInstanceType:
- default: Swarm manager instance type?
- ManagerSize:
- default: Number of Swarm managers?
- WorkerDiskSize:
- default: Worker ephemeral storage volume size?
- WorkerDiskType:
- default: Worker ephemeral storage volume type
-Outputs:
- DefaultDNSTarget:
- Description: Use this name to update your DNS records
- Value: !GetAtt
- - ExternalLoadBalancer
- - DNSName
- ELBDNSZoneID:
- Description: Use this zone ID to update your DNS records
- Value: !GetAtt
- - ExternalLoadBalancer
- - CanonicalHostedZoneNameID
- ManagerSecurityGroupID:
- Description: SecurityGroup ID of ManagerVpcSG
- Value: !Ref ManagerVpcSG
- Managers:
- Description: >-
- You can see the manager nodes associated with this cluster here. Follow
- the instructions here: https://docs.docker.com/docker-for-aws/deploy/
- Value: !Join
- - ''
- - - 'https://'
- - !Ref 'AWS::Region'
- - .console.aws.amazon.com/ec2/v2/home?region=
- - !Ref 'AWS::Region'
- - '#Instances:tag:aws:autoscaling:groupName='
- - !Ref ManagerAsg
- - ';sort=desc:dnsName'
- NodeSecurityGroupID:
- Description: SecurityGroup ID of NodeVpcSG
- Value: !Ref NodeVpcSG
- SwarmWideSecurityGroupID:
- Description: SecurityGroup ID of SwarmWideSG
- Value: !Ref SwarmWideSG
- VPCID:
- Description: Use this as the VPC for configuring Private Hosted Zones
- Value: !Ref Vpc
- ZoneAvailabilityComment:
- Description: Availabilty Zones Comment
- Value: !If
- - HasOnly2AZs
- - >-
- This region only has 2 Availabiliy Zones (AZ). If one of those AZs goes
- away, it will cause problems for your Swarm Managers. Please use a
- Region with at least 3 AZs.
- - >-
- This region has at least 3 Availability Zones (AZ). This is ideal to
- ensure a fully functional Swarm in case you lose an AZ.
-Parameters:
- ClusterSize:
- Default: '0'
- Description: Number of worker nodes in the Swarm (0-1000).
- MaxValue: '1000'
- MinValue: '0'
- Type: Number
- EnableCloudStorEfs:
- AllowedValues:
- - 'no'
- - 'yes'
- Default: 'no'
- Description: Create CloudStor EFS mount targets
- Type: String
- EnableCloudWatchLogs:
- AllowedValues:
- - 'no'
- - 'yes'
- Default: 'yes'
- Description: Send all Container logs to CloudWatch
- Type: String
- EnableEbsOptimized:
- AllowedValues:
- - 'no'
- - 'yes'
- Default: 'no'
- Description: Specifies whether the launch configuration is optimized for EBS I/O
- Type: String
- EnableSystemPrune:
- AllowedValues:
- - 'no'
- - 'yes'
- Default: 'yes'
- Description: 'Cleans up unused images, containers, networks and volumes'
- Type: String
- EncryptEFS:
- AllowedValues:
- - 'false'
- - 'true'
- Default: 'false'
- Description: Specifies whether any EFS objects created will be encrypted
- Type: String
- InstanceType:
- AllowedValues:
- - t2.micro
- - t2.small
- - t3.small
- - t2.medium
- - t2.large
- - t2.xlarge
- - t2.2xlarge
- - m5.large
- - m5.xlarge
- - m5.2xlarge
- - m5.4xlarge
- - m5.12xlarge
- - m5.24xlarge
- - m4.large
- - m4.xlarge
- - m4.2xlarge
- - m4.4xlarge
- - m4.10xlarge
- - m4.16xlarge
- - m3.medium
- - m3.large
- - m3.xlarge
- - m3.2xlarge
- - c4.large
- - c4.xlarge
- - c4.2xlarge
- - c4.4xlarge
- - c4.8xlarge
- - c5.large
- - c5.xlarge
- - c5.2xlarge
- - c5.4xlarge
- - c5.9xlarge
- - c5.18xlarge
- - c3.large
- - c3.xlarge
- - c3.2xlarge
- - c3.4xlarge
- - c3.8xlarge
- - r3.large
- - r3.xlarge
- - r3.2xlarge
- - r3.4xlarge
- - r3.8xlarge
- - r4.large
- - r4.xlarge
- - r4.2xlarge
- - r4.4xlarge
- - r4.8xlarge
- - r4.16xlarge
- - i3.large
- - i3.xlarge
- - i3.2xlarge
- - i3.4xlarge
- - i3.8xlarge
- - i3.16xlarge
- ConstraintDescription: Must be a valid EC2 HVM instance type.
- Default: t3.small
- Description: 'EC2 HVM instance type (t2.micro, m3.medium, etc).'
- Type: String
- KeyName:
- ConstraintDescription: Must be the name of an existing EC2 KeyPair
- Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
- Type: 'AWS::EC2::KeyPair::KeyName'
- ManagerDiskSize:
- Default: '20'
- Description: Size of Manager's ephemeral storage volume in GiB
- MaxValue: '1024'
- MinValue: '20'
- Type: Number
- ManagerDiskType:
- AllowedValues:
- - standard
- - gp2
- Default: standard
- Description: Manager ephemeral storage volume type
- Type: String
- ManagerInstanceType:
- AllowedValues:
- - t2.micro
- - t2.small
- - t3.small
- - t2.medium
- - t2.large
- - t2.xlarge
- - t2.2xlarge
- - m5.large
- - m5.xlarge
- - m5.2xlarge
- - m5.4xlarge
- - m5.12xlarge
- - m5.24xlarge
- - m4.large
- - m4.xlarge
- - m4.2xlarge
- - m4.4xlarge
- - m4.10xlarge
- - m4.16xlarge
- - m3.medium
- - m3.large
- - m3.xlarge
- - m3.2xlarge
- - c4.large
- - c4.xlarge
- - c4.2xlarge
- - c4.4xlarge
- - c4.8xlarge
- - c5.large
- - c5.xlarge
- - c5.2xlarge
- - c5.4xlarge
- - c5.9xlarge
- - c5.18xlarge
- - c3.large
- - c3.xlarge
- - c3.2xlarge
- - c3.4xlarge
- - c3.8xlarge
- - r3.large
- - r3.xlarge
- - r3.2xlarge
- - r3.4xlarge
- - r3.8xlarge
- - r4.large
- - r4.xlarge
- - r4.2xlarge
- - r4.4xlarge
- - r4.8xlarge
- - r4.16xlarge
- - i3.large
- - i3.xlarge
- - i3.2xlarge
- - i3.4xlarge
- - i3.8xlarge
- - i3.16xlarge
- ConstraintDescription: Must be a valid EC2 HVM instance type.
- Default: t3.small
- Description: 'EC2 HVM instance type (t2.micro, m3.medium, etc).'
- Type: String
- ManagerSize:
- AllowedValues:
- - '1'
- - '3'
- - '5'
- Default: '3'
- Description: 'Number of Swarm manager nodes (1, 3, 5)'
- Type: Number
- WorkerDiskSize:
- Default: '20'
- Description: Size of Workers's ephemeral storage volume in GiB
- MaxValue: '1024'
- MinValue: '20'
- Type: Number
- WorkerDiskType:
- AllowedValues:
- - standard
- - gp2
- Default: standard
- Description: Worker ephemeral storage volume type
- Type: String
-Resources:
- AZInfo:
- Condition: LambdaSupported
- Properties:
- Region: !Ref 'AWS::Region'
- ServiceToken: !GetAtt
- - AZInfoFunction
- - Arn
- Type: 'Custom::AZInfo'
- AZInfoFunction:
- Condition: LambdaSupported
- Properties:
- Code:
- ZipFile: !Join
- - |+
-
- - - import cfnresponse
- - import boto3
- - 'def handler(event, context):'
- - ' ec2c = boto3.client(''ec2'')'
- - ' r = ec2c.describe_availability_zones()'
- - ' azs = r.get(''AvailabilityZones'')'
- - ' az_list = [az.get(''ZoneName'') for az in azs if az.get(''State'') == ''available'']'
- - ' az0 = az_list[0]'
- - ' az1 = az_list[1]'
- - ' if len(az_list) > 2:'
- - ' az2 = az_list[2]'
- - ' else:'
- - ' az2 = az0'
- - ' resp = {''AZ0'': az0, ''AZ1'': az1, ''AZ2'': az2}'
- - ' cfnresponse.send(event, context, cfnresponse.SUCCESS, resp)'
- - ' return resp'
- Handler: index.handler
- MemorySize: 128
- Role: !GetAtt
- - LambdaExecutionRole
- - Arn
- Runtime: python2.7
- Timeout: '10'
- Type: 'AWS::Lambda::Function'
- AttachGateway:
- DependsOn:
- - Vpc
- - InternetGateway
- Properties:
- InternetGatewayId: !Ref InternetGateway
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::VPCGatewayAttachment'
- CloudstorEBSPolicy:
- DependsOn:
- - ProxyRole
- - WorkerRole
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'ec2:CreateTags'
- - 'ec2:AttachVolume'
- - 'ec2:DetachVolume'
- - 'ec2:CreateVolume'
- - 'ec2:DeleteVolume'
- - 'ec2:DescribeVolumes'
- - 'ec2:DescribeVolumeStatus'
- - 'ec2:CreateSnapshot'
- - 'ec2:DeleteSnapshot'
- - 'ec2:DescribeSnapshots'
- Effect: Allow
- Resource: '*'
- Version: 2012-10-17
- PolicyName: cloudstor-ebs-policy
- Roles:
- - !Ref ProxyRole
- - !Ref WorkerRole
- Type: 'AWS::IAM::Policy'
- DockerLogGroup:
- Condition: CreateLogResources
- Properties:
- LogGroupName: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - lg
- RetentionInDays: 7
- Type: 'AWS::Logs::LogGroup'
- DynDBPolicies:
- DependsOn:
- - ProxyRole
- - SwarmDynDBTable
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'dynamodb:PutItem'
- - 'dynamodb:DeleteItem'
- - 'dynamodb:GetItem'
- - 'dynamodb:UpdateItem'
- - 'dynamodb:Query'
- Effect: Allow
- Resource: !Join
- - ''
- - - 'arn:aws:dynamodb:'
- - !Ref 'AWS::Region'
- - ':'
- - !Ref 'AWS::AccountId'
- - ':table/'
- - !Ref SwarmDynDBTable
- Version: 2012-10-17
- PolicyName: dyndb-getput
- Roles:
- - !Ref ProxyRole
- Type: 'AWS::IAM::Policy'
- DynDBWorkerPolicies:
- DependsOn:
- - WorkerRole
- - SwarmDynDBTable
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'dynamodb:GetItem'
- - 'dynamodb:Query'
- Effect: Allow
- Resource: !Join
- - ''
- - - 'arn:aws:dynamodb:'
- - !Ref 'AWS::Region'
- - ':'
- - !Ref 'AWS::AccountId'
- - ':table/'
- - !Ref SwarmDynDBTable
- Version: 2012-10-17
- PolicyName: worker-dyndb-get
- Roles:
- - !Ref WorkerRole
- Type: 'AWS::IAM::Policy'
- ECRPolicy:
- DependsOn:
- - ProxyRole
- - WorkerRole
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'ecr:GetAuthorizationToken'
- - 'ecr:BatchCheckLayerAvailability'
- - 'ecr:GetDownloadUrlForLayer'
- - 'ecr:GetRepositoryPolicy'
- - 'ecr:DescribeRepositories'
- - 'ecr:ListImages'
- - 'ecr:DescribeImages'
- - 'ecr:BatchGetImage'
- Effect: Allow
- Resource: '*'
- Version: 2012-10-17
- PolicyName: ecr-policy
- Roles:
- - !Ref ProxyRole
- - !Ref WorkerRole
- Type: 'AWS::IAM::Policy'
- ExternalLoadBalancer:
- DependsOn:
- - AttachGateway
- - ExternalLoadBalancerSG
- - PubSubnetAz1
- - PubSubnetAz2
- - PubSubnetAz3
- Properties:
- ConnectionSettings:
- IdleTimeout: 600
- CrossZone: 'true'
- HealthCheck:
- HealthyThreshold: '2'
- Interval: '10'
- Target: 'HTTP:44554/'
- Timeout: '8'
- UnhealthyThreshold: '4'
- Listeners:
- - InstancePort: '7'
- LoadBalancerPort: '7'
- Protocol: TCP
- SecurityGroups:
- - !Ref ExternalLoadBalancerSG
- Subnets: !If
- - HasOnly2AZs
- - - !Ref PubSubnetAz1
- - !Ref PubSubnetAz2
- - - !Ref PubSubnetAz1
- - !Ref PubSubnetAz2
- - !Ref PubSubnetAz3
- Tags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - ELB
- Type: 'AWS::ElasticLoadBalancing::LoadBalancer'
- ExternalLoadBalancerSG:
- DependsOn: Vpc
- Properties:
- GroupDescription: External Load Balancer SecurityGroup
- SecurityGroupIngress:
- - CidrIp: 0.0.0.0/0
- FromPort: '0'
- IpProtocol: '-1'
- ToPort: '65535'
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::SecurityGroup'
- FileSystemGP:
- Condition: InstallCloudStorEFSPreReqs
- Properties:
- Encrypted: !If
- - EFSEncrypted
- - !Ref EncryptEFS
- - !Ref 'AWS::NoValue'
- FileSystemTags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - EFS-GP
- PerformanceMode: generalPurpose
- Type: 'AWS::EFS::FileSystem'
- FileSystemMaxIO:
- Condition: InstallCloudStorEFSPreReqs
- Properties:
- Encrypted: !If
- - EFSEncrypted
- - !Ref EncryptEFS
- - !Ref 'AWS::NoValue'
- FileSystemTags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - EFS-MaxIO
- PerformanceMode: maxIO
- Type: 'AWS::EFS::FileSystem'
- InternetGateway:
- DependsOn: Vpc
- Properties:
- Tags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - IGW
- Type: 'AWS::EC2::InternetGateway'
- LambdaExecutionRole:
- Condition: LambdaSupported
- Properties:
- AssumeRolePolicyDocument:
- Statement:
- - Action:
- - 'sts:AssumeRole'
- Effect: Allow
- Principal:
- Service:
- - lambda.amazonaws.com
- Version: 2012-10-17
- Path: /
- Policies:
- - PolicyDocument:
- Statement:
- - Action:
- - 'logs:CreateLogGroup'
- - 'logs:CreateLogStream'
- - 'logs:PutLogEvents'
- Effect: Allow
- Resource: 'arn:aws:logs:*:*:*'
- - Action:
- - 'ec2:DescribeAvailabilityZones'
- Effect: Allow
- Resource: '*'
- Version: 2012-10-17
- PolicyName: root
- Type: 'AWS::IAM::Role'
- ManagerAsg:
- CreationPolicy:
- ResourceSignal:
- Count: !Ref ManagerSize
- Timeout: PT20M
- DependsOn:
- - SwarmDynDBTable
- - PubSubnetAz1
- - PubSubnetAz2
- - PubSubnetAz3
- - ExternalLoadBalancer
- Properties:
- DesiredCapacity: !Ref ManagerSize
- HealthCheckGracePeriod: 300
- HealthCheckType: ELB
- LaunchConfigurationName: !Ref ManagerLaunchConfig18092ceaws1
- LoadBalancerNames:
- - !Ref ExternalLoadBalancer
- MaxSize: 6
- MetricsCollection:
- - Granularity: 1Minute
- MinSize: 0
- Tags:
- - Key: Name
- PropagateAtLaunch: true
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - Manager
- - Key: swarm-node-type
- PropagateAtLaunch: true
- Value: manager
- - Key: swarm-stack-id
- PropagateAtLaunch: true
- Value: !Ref 'AWS::StackId'
- - Key: DOCKER_FOR_AWS_VERSION
- PropagateAtLaunch: true
- Value: !FindInMap
- - DockerForAWS
- - version
- - forAws
- - Key: DOCKER_VERSION
- PropagateAtLaunch: true
- Value: !FindInMap
- - DockerForAWS
- - version
- - docker
- VPCZoneIdentifier:
- - !If
- - HasOnly2AZs
- - !Join
- - ','
- - - !Ref PubSubnetAz1
- - !Ref PubSubnetAz2
- - !Join
- - ','
- - - !Ref PubSubnetAz1
- - !Ref PubSubnetAz2
- - !Ref PubSubnetAz3
- Type: 'AWS::AutoScaling::AutoScalingGroup'
- UpdatePolicy:
- AutoScalingRollingUpdate:
- MaxBatchSize: '1'
- MinInstancesInService: !Ref ManagerSize
- PauseTime: PT20M
- WaitOnResourceSignals: 'true'
- ManagerLaunchConfig18092ceaws1:
- DependsOn: ExternalLoadBalancer
- Properties:
- AssociatePublicIpAddress: 'true'
- BlockDeviceMappings:
- - DeviceName: /dev/xvdb
- Ebs:
- VolumeSize: !Ref ManagerDiskSize
- VolumeType: !Ref ManagerDiskType
- EbsOptimized: !If
- - EBSOptimized
- - 'true'
- - 'false'
- IamInstanceProfile: !Ref ProxyInstanceProfile
- ImageId: !FindInMap
- - AWSRegionArch2AMI
- - !Ref 'AWS::Region'
- - !FindInMap
- - AWSInstanceType2Arch
- - !Ref ManagerInstanceType
- - Arch
- InstanceType: !Ref ManagerInstanceType
- KeyName: !Ref KeyName
- SecurityGroups:
- - !Ref ManagerVpcSG
- - !Ref SwarmWideSG
- UserData: !Base64
- 'Fn::Join':
- - ''
- - - |
- #!/bin/sh
- - export EXTERNAL_LB='
- - !Ref ExternalLoadBalancer
- - |
- '
- - export DOCKER_FOR_IAAS_VERSION='
- - !FindInMap
- - DockerForAWS
- - version
- - forAws
- - |
- '
- - export CHANNEL='
- - !FindInMap
- - DockerForAWS
- - version
- - channel
- - |
- '
- - export EDITION_ADDON='
- - !FindInMap
- - DockerForAWS
- - version
- - addOn
- - |
- '
- - >
- export LOCAL_IP=$(wget -qO-
- http://169.254.169.254/latest/meta-data/local-ipv4)
- - >
- export INSTANCE_TYPE=$(wget -qO-
- http://169.254.169.254/latest/meta-data/instance-type)
- - >
- export NODE_AZ=$(wget -qO-
- http://169.254.169.254/latest/meta-data/placement/availability-zone/)
- - |
- export NODE_REGION=$(echo $NODE_AZ | sed 's/.$//')
- - export ENABLE_CLOUDWATCH_LOGS='
- - !Ref EnableCloudWatchLogs
- - |
- '
- - export AWS_REGION='
- - !Ref 'AWS::Region'
- - |
- '
- - export MANAGER_SECURITY_GROUP_ID='
- - !Ref ManagerVpcSG
- - |
- '
- - export WORKER_SECURITY_GROUP_ID='
- - !Ref NodeVpcSG
- - |
- '
- - export DYNAMODB_TABLE='
- - !Ref SwarmDynDBTable
- - |
- '
- - export STACK_NAME='
- - !Ref 'AWS::StackName'
- - |
- '
- - export STACK_ID='
- - !Ref 'AWS::StackId'
- - |
- '
- - export ACCOUNT_ID='
- - !Ref 'AWS::AccountId'
- - |
- '
- - export VPC_ID='
- - !Ref Vpc
- - |
- '
- - export SWARM_QUEUE='
- - !Ref SwarmSQS
- - |
- '
- - export CLEANUP_QUEUE='
- - !Ref SwarmSQSCleanup
- - |
- '
- - export RUN_VACUUM='
- - !Ref EnableSystemPrune
- - |
- '
- - export LOG_GROUP_NAME='
- - !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - lg
- - |
- '
- - export HAS_DDC='
- - !FindInMap
- - DockerForAWS
- - version
- - HasDDC
- - |
- '
- - export ENABLE_EFS='
- - !If
- - InstallCloudStorEFSPreReqs
- - '1'
- - '0'
- - |
- '
- - export EFS_ID_REGULAR='
- - !If
- - InstallCloudStorEFSPreReqs
- - !Ref FileSystemGP
- - ''
- - |
- '
- - export EFS_ID_MAXIO='
- - !If
- - InstallCloudStorEFSPreReqs
- - !Ref FileSystemMaxIO
- - ''
- - |
- '
- - |
- export DOCKER_EXPERIMENTAL='true'
- - |
- export NODE_TYPE='manager'
- - |
- export INSTANCE_NAME='ManagerAsg'
- - |+
-
- - |
- mkdir -p /var/lib/docker/editions
- - |
- echo "$EXTERNAL_LB" > /var/lib/docker/editions/lb_name
- - >
- echo "# hostname : ELB_name" >>
- /var/lib/docker/editions/elb.config
- - >
- echo "127.0.0.1: $EXTERNAL_LB" >>
- /var/lib/docker/editions/elb.config
- - >
- echo "localhost: $EXTERNAL_LB" >>
- /var/lib/docker/editions/elb.config
- - >
- echo "default: $EXTERNAL_LB" >>
- /var/lib/docker/editions/elb.config
- - |+
-
- - >
- echo '{"experimental": '$DOCKER_EXPERIMENTAL',
- "labels":["os=linux", "region='$NODE_REGION'",
- "availability_zone='$NODE_AZ'", "instance_type='$INSTANCE_TYPE'",
- "node_type='$NODE_TYPE'" ]' > /etc/docker/daemon.json
- - |+
-
- - |
- if [ $ENABLE_CLOUDWATCH_LOGS == 'yes' ] ; then
- - |2
- echo ', "log-driver": "awslogs", "log-opts": {"awslogs-group": "'$LOG_GROUP_NAME'", "tag": "{{.Name}}-{{.ID}}" }}' >> /etc/docker/daemon.json
- - |
- else
- - |2
- echo ' }' >> /etc/docker/daemon.json
- - |
- fi
- - |+
-
- - |
- chown -R docker /home/docker/
- - |
- chgrp -R docker /home/docker/
- - |
- rc-service docker restart
- - |
- sleep 5
- - |+
-
- - |
- # init-aws
- - >
- docker run --label com.docker.editions.system
- --log-driver=json-file --restart=no -d -e
- DYNAMODB_TABLE=$DYNAMODB_TABLE -e NODE_TYPE=$NODE_TYPE -e
- REGION=$AWS_REGION -e STACK_NAME=$STACK_NAME -e
- STACK_ID="$STACK_ID" -e ACCOUNT_ID=$ACCOUNT_ID -e
- INSTANCE_NAME=$INSTANCE_NAME -e
- DOCKER_FOR_IAAS_VERSION=$DOCKER_FOR_IAAS_VERSION -e
- EDITION_ADDON=$EDITION_ADDON -e HAS_DDC=$HAS_DDC -v
- /var/run/docker.sock:/var/run/docker.sock -v /var/log:/var/log
- docker4x/init-aws:$DOCKER_FOR_IAAS_VERSION
- - |+
-
- - |
- # guide-aws
- - >
- docker run --label com.docker.editions.system
- --log-driver=json-file --log-opt max-size=50m --name=guide-aws
- --restart=always -d -e DYNAMODB_TABLE=$DYNAMODB_TABLE -e
- NODE_TYPE=$NODE_TYPE -e REGION=$AWS_REGION -e
- STACK_NAME=$STACK_NAME -e INSTANCE_NAME=$INSTANCE_NAME -e
- VPC_ID=$VPC_ID -e STACK_ID="$STACK_ID" -e ACCOUNT_ID=$ACCOUNT_ID
- -e SWARM_QUEUE="$SWARM_QUEUE" -e CLEANUP_QUEUE="$CLEANUP_QUEUE" -e
- RUN_VACUUM=$RUN_VACUUM -e
- DOCKER_FOR_IAAS_VERSION=$DOCKER_FOR_IAAS_VERSION -e
- EDITION_ADDON=$EDITION_ADDON -e HAS_DDC=$HAS_DDC -e
- CHANNEL=$CHANNEL -v /var/run/docker.sock:/var/run/docker.sock
- docker4x/guide-aws:$DOCKER_FOR_IAAS_VERSION
- - |+
-
- - |
- # cloudstor
- - >
- docker plugin install --alias cloudstor:aws
- --grant-all-permissions
- docker4x/cloudstor:$DOCKER_FOR_IAAS_VERSION CLOUD_PLATFORM=AWS
- EFS_ID_REGULAR=$EFS_ID_REGULAR EFS_ID_MAXIO=$EFS_ID_MAXIO
- AWS_REGION=$AWS_REGION AWS_STACK_ID=$STACK_ID
- EFS_SUPPORTED=$ENABLE_EFS DEBUG=1
- - >
- docker run --label com.docker.editions.system
- --log-driver=json-file --log-opt max-size=50m --name=meta-aws
- --restart=always -d -p $LOCAL_IP:9024:8080 -e
- AWS_REGION=$AWS_REGION -e
- MANAGER_SECURITY_GROUP_ID=$MANAGER_SECURITY_GROUP_ID -e
- WORKER_SECURITY_GROUP_ID=$WORKER_SECURITY_GROUP_ID -v
- /var/run/docker.sock:/var/run/docker.sock
- docker4x/meta-aws:$DOCKER_FOR_IAAS_VERSION metaserver
- -iaas_provider=aws
- - >
- docker run --label com.docker.editions.system
- --log-driver=json-file --log-opt max-size=50m
- --name=l4controller-aws --restart=always -d -v
- /var/run/docker.sock:/var/run/docker.sock -v
- /var/lib/docker/editions:/var/lib/docker/editions
- docker4x/l4controller-aws:$DOCKER_FOR_IAAS_VERSION run --log=4
- --all=true
- Type: 'AWS::AutoScaling::LaunchConfiguration'
- ManagerVpcSG:
- DependsOn: NodeVpcSG
- Properties:
- GroupDescription: Manager SecurityGroup
- SecurityGroupIngress:
- - CidrIp: 0.0.0.0/0
- FromPort: '22'
- IpProtocol: tcp
- ToPort: '22'
- - IpProtocol: '50'
- SourceSecurityGroupId: !GetAtt
- - NodeVpcSG
- - GroupId
- - FromPort: '2377'
- IpProtocol: tcp
- SourceSecurityGroupId: !GetAtt
- - NodeVpcSG
- - GroupId
- ToPort: '2377'
- - FromPort: '4789'
- IpProtocol: udp
- SourceSecurityGroupId: !GetAtt
- - NodeVpcSG
- - GroupId
- ToPort: '4789'
- - FromPort: '7946'
- IpProtocol: tcp
- SourceSecurityGroupId: !GetAtt
- - NodeVpcSG
- - GroupId
- ToPort: '7946'
- - FromPort: '7946'
- IpProtocol: udp
- SourceSecurityGroupId: !GetAtt
- - NodeVpcSG
- - GroupId
- ToPort: '7946'
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::SecurityGroup'
- MountTargetGP1:
- Condition: InstallCloudStorEFSPreReqs
- DependsOn:
- - FileSystemGP
- - SwarmWideSG
- Properties:
- FileSystemId: !Ref FileSystemGP
- SecurityGroups:
- - !Ref SwarmWideSG
- SubnetId: !Ref PubSubnetAz1
- Type: 'AWS::EFS::MountTarget'
- MountTargetGP2:
- Condition: InstallCloudStorEFSPreReqs
- DependsOn:
- - FileSystemGP
- - SwarmWideSG
- Properties:
- FileSystemId: !Ref FileSystemGP
- SecurityGroups:
- - !Ref SwarmWideSG
- SubnetId: !Ref PubSubnetAz2
- Type: 'AWS::EFS::MountTarget'
- MountTargetGP3:
- Condition: InstallCloudStorEFSPreReqs
- DependsOn:
- - FileSystemGP
- - SwarmWideSG
- Properties:
- FileSystemId: !Ref FileSystemGP
- SecurityGroups:
- - !Ref SwarmWideSG
- SubnetId: !Ref PubSubnetAz3
- Type: 'AWS::EFS::MountTarget'
- MountTargetMaxIO1:
- Condition: InstallCloudStorEFSPreReqs
- DependsOn:
- - FileSystemMaxIO
- - SwarmWideSG
- Properties:
- FileSystemId: !Ref FileSystemMaxIO
- SecurityGroups:
- - !Ref SwarmWideSG
- SubnetId: !Ref PubSubnetAz1
- Type: 'AWS::EFS::MountTarget'
- MountTargetMaxIO2:
- Condition: InstallCloudStorEFSPreReqs
- DependsOn:
- - FileSystemMaxIO
- - SwarmWideSG
- Properties:
- FileSystemId: !Ref FileSystemMaxIO
- SecurityGroups:
- - !Ref SwarmWideSG
- SubnetId: !Ref PubSubnetAz2
- Type: 'AWS::EFS::MountTarget'
- MountTargetMaxIO3:
- Condition: InstallCloudStorEFSPreReqs
- DependsOn:
- - FileSystemMaxIO
- - SwarmWideSG
- Properties:
- FileSystemId: !Ref FileSystemMaxIO
- SecurityGroups:
- - !Ref SwarmWideSG
- SubnetId: !Ref PubSubnetAz3
- Type: 'AWS::EFS::MountTarget'
- NodeAsg:
- CreationPolicy:
- ResourceSignal:
- Count: !Ref ClusterSize
- Timeout: PT20M
- DependsOn: ManagerAsg
- Properties:
- DesiredCapacity: !Ref ClusterSize
- HealthCheckGracePeriod: 300
- HealthCheckType: ELB
- LaunchConfigurationName: !Ref NodeLaunchConfig18092ceaws1
- LoadBalancerNames:
- - !Ref ExternalLoadBalancer
- MaxSize: 1000
- MetricsCollection:
- - Granularity: 1Minute
- MinSize: 0
- Tags:
- - Key: Name
- PropagateAtLaunch: true
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - worker
- - Key: swarm-node-type
- PropagateAtLaunch: true
- Value: worker
- - Key: swarm-stack-id
- PropagateAtLaunch: true
- Value: !Ref 'AWS::StackId'
- - Key: DOCKER_FOR_AWS_VERSION
- PropagateAtLaunch: true
- Value: !FindInMap
- - DockerForAWS
- - version
- - forAws
- - Key: DOCKER_VERSION
- PropagateAtLaunch: true
- Value: !FindInMap
- - DockerForAWS
- - version
- - docker
- VPCZoneIdentifier:
- - !If
- - HasOnly2AZs
- - !Join
- - ','
- - - !Ref PubSubnetAz1
- - !Ref PubSubnetAz2
- - !Join
- - ','
- - - !Ref PubSubnetAz1
- - !Ref PubSubnetAz2
- - !Ref PubSubnetAz3
- Type: 'AWS::AutoScaling::AutoScalingGroup'
- UpdatePolicy:
- AutoScalingRollingUpdate:
- MaxBatchSize: '1'
- MinInstancesInService: !Ref ClusterSize
- PauseTime: PT20M
- WaitOnResourceSignals: 'true'
- NodeLaunchConfig18092ceaws1:
- DependsOn: ManagerAsg
- Properties:
- AssociatePublicIpAddress: 'true'
- BlockDeviceMappings:
- - DeviceName: /dev/xvdb
- Ebs:
- VolumeSize: !Ref WorkerDiskSize
- VolumeType: !Ref WorkerDiskType
- EbsOptimized: !If
- - EBSOptimized
- - 'true'
- - 'false'
- IamInstanceProfile: !Ref WorkerInstanceProfile
- ImageId: !FindInMap
- - AWSRegionArch2AMI
- - !Ref 'AWS::Region'
- - !FindInMap
- - AWSInstanceType2Arch
- - !Ref InstanceType
- - Arch
- InstanceType: !Ref InstanceType
- KeyName: !Ref KeyName
- SecurityGroups:
- - !Ref NodeVpcSG
- UserData: !Base64
- 'Fn::Join':
- - ''
- - - |
- #!/bin/sh
- - export EXTERNAL_LB='
- - !Ref ExternalLoadBalancer
- - |
- '
- - export DOCKER_FOR_IAAS_VERSION='
- - !FindInMap
- - DockerForAWS
- - version
- - forAws
- - |
- '
- - export CHANNEL='
- - !FindInMap
- - DockerForAWS
- - version
- - channel
- - |
- '
- - export EDITION_ADDON='
- - !FindInMap
- - DockerForAWS
- - version
- - addOn
- - |
- '
- - >
- export LOCAL_IP=$(wget -qO-
- http://169.254.169.254/latest/meta-data/local-ipv4)
- - >
- export INSTANCE_TYPE=$(wget -qO-
- http://169.254.169.254/latest/meta-data/instance-type)
- - >
- export NODE_AZ=$(wget -qO-
- http://169.254.169.254/latest/meta-data/placement/availability-zone/)
- - |
- export NODE_REGION=$(echo $NODE_AZ | sed 's/.$//')
- - export ENABLE_CLOUDWATCH_LOGS='
- - !Ref EnableCloudWatchLogs
- - |
- '
- - export AWS_REGION='
- - !Ref 'AWS::Region'
- - |
- '
- - export MANAGER_SECURITY_GROUP_ID='
- - !Ref ManagerVpcSG
- - |
- '
- - export WORKER_SECURITY_GROUP_ID='
- - !Ref NodeVpcSG
- - |
- '
- - export DYNAMODB_TABLE='
- - !Ref SwarmDynDBTable
- - |
- '
- - export STACK_NAME='
- - !Ref 'AWS::StackName'
- - |
- '
- - export STACK_ID='
- - !Ref 'AWS::StackId'
- - |
- '
- - export ACCOUNT_ID='
- - !Ref 'AWS::AccountId'
- - |
- '
- - export VPC_ID='
- - !Ref Vpc
- - |
- '
- - export SWARM_QUEUE='
- - !Ref SwarmSQS
- - |
- '
- - export CLEANUP_QUEUE='
- - !Ref SwarmSQSCleanup
- - |
- '
- - export RUN_VACUUM='
- - !Ref EnableSystemPrune
- - |
- '
- - export LOG_GROUP_NAME='
- - !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - lg
- - |
- '
- - export HAS_DDC='
- - !FindInMap
- - DockerForAWS
- - version
- - HasDDC
- - |
- '
- - export ENABLE_EFS='
- - !If
- - InstallCloudStorEFSPreReqs
- - '1'
- - '0'
- - |
- '
- - export EFS_ID_REGULAR='
- - !If
- - InstallCloudStorEFSPreReqs
- - !Ref FileSystemGP
- - ''
- - |
- '
- - export EFS_ID_MAXIO='
- - !If
- - InstallCloudStorEFSPreReqs
- - !Ref FileSystemMaxIO
- - ''
- - |
- '
- - |
- export DOCKER_EXPERIMENTAL='true'
- - |
- export NODE_TYPE='worker'
- - |
- export INSTANCE_NAME='NodeAsg'
- - |+
-
- - |
- mkdir -p /var/lib/docker/editions
- - |
- echo "$EXTERNAL_LB" > /var/lib/docker/editions/lb_name
- - >
- echo "# hostname : ELB_name" >>
- /var/lib/docker/editions/elb.config
- - >
- echo "127.0.0.1: $EXTERNAL_LB" >>
- /var/lib/docker/editions/elb.config
- - >
- echo "localhost: $EXTERNAL_LB" >>
- /var/lib/docker/editions/elb.config
- - >
- echo "default: $EXTERNAL_LB" >>
- /var/lib/docker/editions/elb.config
- - |+
-
- - >
- echo '{"experimental": '$DOCKER_EXPERIMENTAL',
- "labels":["os=linux", "region='$NODE_REGION'",
- "availability_zone='$NODE_AZ'", "instance_type='$INSTANCE_TYPE'",
- "node_type='$NODE_TYPE'" ]' > /etc/docker/daemon.json
- - |+
-
- - |
- if [ $ENABLE_CLOUDWATCH_LOGS == 'yes' ] ; then
- - |2
- echo ', "log-driver": "awslogs", "log-opts": {"awslogs-group": "'$LOG_GROUP_NAME'", "tag": "{{.Name}}-{{.ID}}" }}' >> /etc/docker/daemon.json
- - |
- else
- - |2
- echo ' }' >> /etc/docker/daemon.json
- - |
- fi
- - |+
-
- - |
- chown -R docker /home/docker/
- - |
- chgrp -R docker /home/docker/
- - |
- rc-service docker restart
- - |
- sleep 5
- - |+
-
- - |
- # init-aws
- - >
- docker run --label com.docker.editions.system
- --log-driver=json-file --restart=no -d -e
- DYNAMODB_TABLE=$DYNAMODB_TABLE -e NODE_TYPE=$NODE_TYPE -e
- REGION=$AWS_REGION -e STACK_NAME=$STACK_NAME -e
- STACK_ID="$STACK_ID" -e ACCOUNT_ID=$ACCOUNT_ID -e
- INSTANCE_NAME=$INSTANCE_NAME -e
- DOCKER_FOR_IAAS_VERSION=$DOCKER_FOR_IAAS_VERSION -e
- EDITION_ADDON=$EDITION_ADDON -e HAS_DDC=$HAS_DDC -v
- /var/run/docker.sock:/var/run/docker.sock -v /var/log:/var/log
- docker4x/init-aws:$DOCKER_FOR_IAAS_VERSION
- - |+
-
- - |
- # guide-aws
- - >
- docker run --label com.docker.editions.system
- --log-driver=json-file --log-opt max-size=50m --name=guide-aws
- --restart=always -d -e DYNAMODB_TABLE=$DYNAMODB_TABLE -e
- NODE_TYPE=$NODE_TYPE -e REGION=$AWS_REGION -e
- STACK_NAME=$STACK_NAME -e INSTANCE_NAME=$INSTANCE_NAME -e
- VPC_ID=$VPC_ID -e STACK_ID="$STACK_ID" -e ACCOUNT_ID=$ACCOUNT_ID
- -e SWARM_QUEUE="$SWARM_QUEUE" -e CLEANUP_QUEUE="$CLEANUP_QUEUE" -e
- RUN_VACUUM=$RUN_VACUUM -e
- DOCKER_FOR_IAAS_VERSION=$DOCKER_FOR_IAAS_VERSION -e
- EDITION_ADDON=$EDITION_ADDON -e HAS_DDC=$HAS_DDC -e
- CHANNEL=$CHANNEL -v /var/run/docker.sock:/var/run/docker.sock
- docker4x/guide-aws:$DOCKER_FOR_IAAS_VERSION
- - |+
-
- - |
- # cloudstor
- - >
- docker plugin install --alias cloudstor:aws
- --grant-all-permissions
- docker4x/cloudstor:$DOCKER_FOR_IAAS_VERSION CLOUD_PLATFORM=AWS
- EFS_ID_REGULAR=$EFS_ID_REGULAR EFS_ID_MAXIO=$EFS_ID_MAXIO
- AWS_REGION=$AWS_REGION AWS_STACK_ID=$STACK_ID
- EFS_SUPPORTED=$ENABLE_EFS DEBUG=1
- - |
- # Worker user data
- Type: 'AWS::AutoScaling::LaunchConfiguration'
- NodeVpcSG:
- DependsOn: Vpc
- Properties:
- GroupDescription: Node SecurityGroup
- SecurityGroupEgress:
- - CidrIp: 0.0.0.0/0
- FromPort: '8'
- IpProtocol: icmp
- ToPort: '0'
- - CidrIp: 0.0.0.0/0
- IpProtocol: '50'
- - CidrIp: 0.0.0.0/0
- FromPort: '0'
- IpProtocol: udp
- ToPort: '65535'
- - CidrIp: 0.0.0.0/0
- FromPort: '0'
- IpProtocol: tcp
- ToPort: '2374'
- - CidrIp: 0.0.0.0/0
- FromPort: '2376'
- IpProtocol: tcp
- ToPort: '65535'
- SecurityGroupIngress:
- - CidrIp: !FindInMap
- - VpcCidrs
- - vpc
- - cidr
- FromPort: '0'
- IpProtocol: '-1'
- ToPort: '65535'
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::SecurityGroup'
- ProxyInstanceProfile:
- DependsOn: ProxyRole
- Properties:
- Path: /
- Roles:
- - !Ref ProxyRole
- Type: 'AWS::IAM::InstanceProfile'
- ProxyPolicies:
- DependsOn: ProxyRole
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'elasticloadbalancing:DeregisterInstancesFromLoadBalancer'
- - 'elasticloadbalancing:CreateLoadBalancerListeners'
- - 'elasticloadbalancing:DeleteLoadBalancerListeners'
- - 'elasticloadbalancing:ConfigureHealthCheck'
- - 'elasticloadbalancing:DescribeTags'
- - 'elasticloadbalancing:SetLoadBalancerListenerSSLCertificate'
- - 'elasticloadbalancing:DescribeSSLPolicies'
- - 'elasticloadbalancing:DescribeLoadBalancers'
- Effect: Allow
- Resource: '*'
- Version: 2012-10-17
- PolicyName: elb-update
- Roles:
- - !Ref ProxyRole
- Type: 'AWS::IAM::Policy'
- ProxyRole:
- Properties:
- AssumeRolePolicyDocument:
- Statement:
- - Action:
- - 'sts:AssumeRole'
- Effect: Allow
- Principal:
- Service:
- - ec2.amazonaws.com
- - autoscaling.amazonaws.com
- Version: 2012-10-17
- Path: /
- Type: 'AWS::IAM::Role'
- PubSubnet1RouteTableAssociation:
- DependsOn:
- - PubSubnetAz1
- - RouteViaIgw
- Properties:
- RouteTableId: !Ref RouteViaIgw
- SubnetId: !Ref PubSubnetAz1
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- PubSubnet2RouteTableAssociation:
- DependsOn:
- - PubSubnetAz2
- - RouteViaIgw
- Properties:
- RouteTableId: !Ref RouteViaIgw
- SubnetId: !Ref PubSubnetAz2
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- PubSubnet3RouteTableAssociation:
- DependsOn:
- - PubSubnetAz3
- - RouteViaIgw
- Properties:
- RouteTableId: !Ref RouteViaIgw
- SubnetId: !Ref PubSubnetAz3
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- PubSubnetAz1:
- DependsOn: Vpc
- Properties:
- AvailabilityZone: !If
- - LambdaSupported
- - !GetAtt
- - AZInfo
- - AZ0
- - !Select
- - !FindInMap
- - AWSRegion2AZ
- - !Ref 'AWS::Region'
- - AZ0
- - !GetAZs
- Ref: 'AWS::Region'
- CidrBlock: !FindInMap
- - VpcCidrs
- - pubsubnet1
- - cidr
- Tags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - Subnet1
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::Subnet'
- PubSubnetAz2:
- DependsOn: Vpc
- Properties:
- AvailabilityZone: !If
- - LambdaSupported
- - !GetAtt
- - AZInfo
- - AZ1
- - !Select
- - !FindInMap
- - AWSRegion2AZ
- - !Ref 'AWS::Region'
- - AZ1
- - !GetAZs
- Ref: 'AWS::Region'
- CidrBlock: !FindInMap
- - VpcCidrs
- - pubsubnet2
- - cidr
- Tags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - Subnet2
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::Subnet'
- PubSubnetAz3:
- DependsOn: Vpc
- Properties:
- AvailabilityZone: !If
- - LambdaSupported
- - !GetAtt
- - AZInfo
- - AZ2
- - !Select
- - !FindInMap
- - AWSRegion2AZ
- - !Ref 'AWS::Region'
- - AZ2
- - !GetAZs
- Ref: 'AWS::Region'
- CidrBlock: !FindInMap
- - VpcCidrs
- - pubsubnet3
- - cidr
- Tags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - Subnet3
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::Subnet'
- PublicRouteViaIgw:
- DependsOn:
- - AttachGateway
- - RouteViaIgw
- Properties:
- DestinationCidrBlock: 0.0.0.0/0
- GatewayId: !Ref InternetGateway
- RouteTableId: !Ref RouteViaIgw
- Type: 'AWS::EC2::Route'
- RouteViaIgw:
- DependsOn: Vpc
- Properties:
- Tags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - RT
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::RouteTable'
- SwarmAPIPolicy:
- DependsOn: ProxyRole
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'ec2:DescribeInstances'
- - 'ec2:DescribeVpcAttribute'
- Effect: Allow
- Resource: '*'
- Version: 2012-10-17
- PolicyName: swarm-policy
- Roles:
- - !Ref ProxyRole
- Type: 'AWS::IAM::Policy'
- SwarmAutoscalePolicy:
- DependsOn:
- - ProxyRole
- - WorkerRole
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'autoscaling:RecordLifecycleActionHeartbeat'
- - 'autoscaling:CompleteLifecycleAction'
- Effect: Allow
- Resource: '*'
- Version: 2012-10-17
- PolicyName: swarm-autoscale-policy
- Roles:
- - !Ref ProxyRole
- - !Ref WorkerRole
- Type: 'AWS::IAM::Policy'
- SwarmDynDBTable:
- DependsOn: ExternalLoadBalancer
- Properties:
- AttributeDefinitions:
- - AttributeName: node_type
- AttributeType: S
- KeySchema:
- - AttributeName: node_type
- KeyType: HASH
- ProvisionedThroughput:
- ReadCapacityUnits: 1
- WriteCapacityUnits: 1
- TableName: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - dyndbtable
- Type: 'AWS::DynamoDB::Table'
- SwarmLogPolicy:
- DependsOn:
- - ProxyRole
- - WorkerRole
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'logs:CreateLogStream'
- - 'logs:PutLogEvents'
- Effect: Allow
- Resource: '*'
- Version: 2012-10-17
- PolicyName: swarm-log-policy
- Roles:
- - !Ref ProxyRole
- - !Ref WorkerRole
- Type: 'AWS::IAM::Policy'
- SwarmManagerUpgradeHook:
- DependsOn: SwarmSQS
- Properties:
- AutoScalingGroupName: !Ref ManagerAsg
- HeartbeatTimeout: '600'
- LifecycleTransition: 'autoscaling:EC2_INSTANCE_TERMINATING'
- NotificationTargetARN: !GetAtt
- - SwarmSQS
- - Arn
- RoleARN: !GetAtt
- - ProxyRole
- - Arn
- Type: 'AWS::AutoScaling::LifecycleHook'
- SwarmSQS:
- Properties:
- MessageRetentionPeriod: 43200
- ReceiveMessageWaitTimeSeconds: 10
- Type: 'AWS::SQS::Queue'
- SwarmSQSCleanup:
- Properties:
- MessageRetentionPeriod: 43200
- ReceiveMessageWaitTimeSeconds: 10
- Type: 'AWS::SQS::Queue'
- SwarmSQSCleanupPolicy:
- DependsOn:
- - ProxyRole
- - WorkerRole
- - SwarmSQSCleanup
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'sqs:DeleteMessage'
- - 'sqs:ReceiveMessage'
- - 'sqs:SendMessage'
- - 'sqs:GetQueueAttributes'
- - 'sqs:GetQueueUrl'
- - 'sqs:ListQueues'
- Effect: Allow
- Resource: !GetAtt
- - SwarmSQSCleanup
- - Arn
- Version: 2012-10-17
- PolicyName: swarm-sqs-cleanup-policy
- Roles:
- - !Ref ProxyRole
- - !Ref WorkerRole
- Type: 'AWS::IAM::Policy'
- SwarmSQSPolicy:
- DependsOn:
- - ProxyRole
- - WorkerRole
- - SwarmSQS
- Properties:
- PolicyDocument:
- Statement:
- - Action:
- - 'sqs:DeleteMessage'
- - 'sqs:ReceiveMessage'
- - 'sqs:SendMessage'
- - 'sqs:GetQueueAttributes'
- - 'sqs:GetQueueUrl'
- - 'sqs:ListQueues'
- Effect: Allow
- Resource: !GetAtt
- - SwarmSQS
- - Arn
- Version: 2012-10-17
- PolicyName: swarm-sqs-policy
- Roles:
- - !Ref ProxyRole
- - !Ref WorkerRole
- Type: 'AWS::IAM::Policy'
- SwarmWideSG:
- DependsOn: Vpc
- Properties:
- GroupDescription: Swarm wide access
- SecurityGroupIngress:
- - CidrIp: !FindInMap
- - VpcCidrs
- - vpc
- - cidr
- FromPort: '0'
- IpProtocol: '-1'
- ToPort: '65535'
- VpcId: !Ref Vpc
- Type: 'AWS::EC2::SecurityGroup'
- SwarmWorkerUpgradeHook:
- DependsOn: SwarmSQS
- Properties:
- AutoScalingGroupName: !Ref NodeAsg
- HeartbeatTimeout: '600'
- LifecycleTransition: 'autoscaling:EC2_INSTANCE_TERMINATING'
- NotificationTargetARN: !GetAtt
- - SwarmSQS
- - Arn
- RoleARN: !GetAtt
- - WorkerRole
- - Arn
- Type: 'AWS::AutoScaling::LifecycleHook'
- Vpc:
- Properties:
- CidrBlock: !FindInMap
- - VpcCidrs
- - vpc
- - cidr
- EnableDnsHostnames: 'true'
- EnableDnsSupport: 'true'
- Tags:
- - Key: Name
- Value: !Join
- - '-'
- - - !Ref 'AWS::StackName'
- - VPC
- Type: 'AWS::EC2::VPC'
- WorkerInstanceProfile:
- DependsOn: WorkerRole
- Properties:
- Path: /
- Roles:
- - !Ref WorkerRole
- Type: 'AWS::IAM::InstanceProfile'
- WorkerRole:
- Properties:
- AssumeRolePolicyDocument:
- Statement:
- - Action:
- - 'sts:AssumeRole'
- Effect: Allow
- Principal:
- Service:
- - ec2.amazonaws.com
- - autoscaling.amazonaws.com
- Version: 2012-10-17
- Path: /
- Type: 'AWS::IAM::Role'
diff --git a/.ci_cd/swarm/k8s.yml b/.ci_cd/swarm/k8s.yml
deleted file mode 100644
index 85bf4a3a2..000000000
--- a/.ci_cd/swarm/k8s.yml
+++ /dev/null
@@ -1,277 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: keycloak
- name: keycloak
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: keycloak
- strategy: {}
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: keycloak
- spec:
- containers:
- - env:
- - name: JAVA_OPTS
- value: -Xms300m -Xmx300m -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=200m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman
- -Djava.awt.headless=true
- - name: KEYCLOAK_LOGLEVEL
- value: INFO
- - name: KEYCLOAK_PASSWORD
- value: secret
- - name: KEYCLOAK_USER
- value: admin
- - name: PROXY_ADDRESS_FORWARDING
- value: "true"
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/keycloak:latest
- imagePullPolicy: ""
- name: keycloak
- ports:
- - containerPort: 8080
- resources: {}
- restartPolicy: Always
- serviceAccountName: ""
- volumes: null
-status: {}
----
-apiVersion: v1
-kind: Service
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: keycloak
- name: keycloak
-spec:
- ports:
- - name: "8081"
- port: 8081
- targetPort: 8080
- selector:
- io.kompose.service: keycloak
-status:
- loadBalancer: {}
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: manager
- name: manager
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: manager
- strategy: {}
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: manager
- spec:
- containers:
- - env:
- - name: EXTERNAL_URL
- value: https://localhost
- - name: JAVA_OPTS
- value: -Xms400m -Xmx400m -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- - name: KEYCLOAK_HOST
- value: keycloak
- - name: KEYCLOAK_PORT
- value: "8080"
- - name: SETUP_ADMIN_PASSWORD
- value: secret
- - name: SETUP_WIPE_CLEAN_INSTALL
- value: "true"
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/manager-swarm:latest
- imagePullPolicy: ""
- name: manager
- resources: {}
- restartPolicy: Always
- serviceAccountName: ""
- volumes: null
-status: {}
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- creationTimestamp: null
- labels:
- io.kompose.service: postgresql-data
- name: postgresql-data
-spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 100Mi
-status: {}
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: postgresql
- name: postgresql
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: postgresql
- strategy:
- type: Recreate
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: postgresql
- spec:
- containers:
- - env:
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/postgresql:latest
- imagePullPolicy: ""
- name: postgresql
- resources: {}
- volumeMounts:
- - mountPath: /var/lib/postgresql/data
- name: postgresql-data
- restartPolicy: Always
- serviceAccountName: ""
- volumes:
- - name: postgresql-data
- persistentVolumeClaim:
- claimName: postgresql-data
-status: {}
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- creationTimestamp: null
- labels:
- io.kompose.service: proxy-data
- name: proxy-data
-spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 100Mi
-status: {}
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: proxy
- name: proxy
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: proxy
- strategy:
- type: Recreate
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: proxy
- spec:
- containers:
- - args:
- - run
- env:
- - name: DOMAINNAME
- value: localhost
- - name: LE_EMAIL
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/proxy:latest
- imagePullPolicy: ""
- name: proxy
- ports:
- - containerPort: 80
- - containerPort: 443
- resources: {}
- volumeMounts:
- - mountPath: /deployment
- name: proxy-data
- restartPolicy: Always
- serviceAccountName: ""
- volumes:
- - name: proxy-data
- persistentVolumeClaim:
- claimName: proxy-data
-status: {}
----
-apiVersion: v1
-kind: Service
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: proxy
- name: proxy
-spec:
- ports:
- - name: "80"
- port: 80
- targetPort: 80
- - name: "443"
- port: 443
- targetPort: 443
- selector:
- io.kompose.service: proxy
-status:
- loadBalancer: {}
diff --git a/.ci_cd/swarm/kube-docker-compose.yml b/.ci_cd/swarm/kube-docker-compose.yml
deleted file mode 100644
index 19df9f17c..000000000
--- a/.ci_cd/swarm/kube-docker-compose.yml
+++ /dev/null
@@ -1,192 +0,0 @@
-# OpenRemote v3
-#
-# By default running this profile installs the stack in swarm on https://localhost using a
-# self-signed SSL certificate, with username 'admin' and password 'secret'.
-#
-# Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.
-#
-# Start a demo stack in the project root directory with:
-#
-# dosker swarm init
-# docker pull openremote/deployment
-# docker-compose -p demo up -d --no-build deployment
-# docker stack deploy --compose-file docker-compose-swarm.yml demo
-#
-# Stop the stack:
-#
-# docker stack rm demo
-#
-# For full documentation, see profile/deploy.yml
-#
-# For swarm (production) use version 3, for developement use version 2
-version: '3.7'
-
-# If you enable volume mappings in services, you need this. Otherwise, remove the volumes
-volumes:
- proxy-data:
- postgresql-data:
-
-services:
-
- proxy:
-
- image: openremote/proxy:${DATE_TAG:-latest}
- environment:
- TZ: Europe/Amsterdam
- DOMAINNAME: ${DOMAINNAME:-localhost}
- LE_EMAIL: ${LE_EMAIL:[email protected]}
-
- # Enable --staging will manage fake certificates, so avoid hitting the rate limits of Let's Encrypt
- # when testing (this is important, you are limited to 5 duplicate certificates per week!)
- # LE_EXTRA_ARGS: '--staging --logs-dir=/etc/letsencrypt'
-
- # The proxy supports up to 10 custom redirects from hostname to any path on the
- # backend service. This can be used to give consoles a vanity domain name.
- # PROXY_HOST_REDIRECT_1_NAME: www.my-console-master.tld
- # PROXY_HOST_REDIRECT_1_TARGET: /console/master
- # PROXY_HOST_REDIRECT_2_NAME: www.my-console-tenant-a.tld
- # PROXY_HOST_REDIRECT_2_TARGET: /console/building
- # PROXY_HOST_REDIRECT_3_NAME: ...
-
- # Customize proxy log, defaults to 'notice', requests are logged at 'info'.
- # Available levels are: emerg, alert, crit, err, warning, notice, info, debug
- # PROXY_LOGLEVEL: 'notice'
-
- # Run proxy, obtain and automatically renew SSL certificates if DOMAINNAME is not localhost. Use
- # the command 'help' to get a list of all options.
- command: run
-
- # Expose a public web service mapped to ports on the host.
- ports:
- - "80:80"
- - "443:443"
-
- volumes:
- - proxy-data:/deployment
- # Override the haproxy.cfg with custom file
- # -${MY_PROXY_CONFIG_FILE}:/etc/haproxy/haproxy.cfg
-
- deploy:
- replicas: 1
-
- # This configuration uses the manager's deployment-specific data such as map tiles,
- # console application static resources (HTML, JS, CSS), extensions, and other
- # configuration files which were baked into the managers image.
- manager:
-
- image: openremote/manager-swarm:${DATE_TAG:-latest}
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # If developer mode is enabled, all setup tasks will be executed on application startup.
- # This will clean all data in the database, and then import demo/test data. Some caching and
- # other runtime performance-optimizations will also be disabled.
- DEV_MODE: ${DEV_MODE:-false}
-
- # This switch can wipe your database, this is the factory reset!
- SETUP_WIPE_CLEAN_INSTALL: ${SETUP_WIPE_CLEAN_INSTALL:-true}
- SETUP_ADMIN_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # When you are ready to permanently install your project, replace it with the next lines...
- # SETUP_WIPE_CLEAN_INSTALL: # Allow override on CLI
-
- # Configure SMTP smart host, to send password reset emails etc.
- #SETUP_EMAIL_HOST: smtp-host.demo.tld
- #SETUP_EMAIL_USER: 'smtp-user'
- #SETUP_EMAIL_PASSWORD: 'smtp-password'
- #SETUP_EMAIL_PORT: 25
- #SETUP_EMAIL_TLS: 'true'
- #SETUP_EMAIL_FROM_KEYCLOAK: '[email protected]'
- #SETUP_EMAIL_FROM_DEFAULT: '[email protected]'
-
- # The public URL of the proxy in front of this manager; must match the proxy#DOMAINNAME (unfortunately
- # docker compose doesn't support chaining environment variables at time of writing, hence the need for
- # two environment variables)
- EXTERNAL_URL: ${EXTERNAL_URL:-https://localhost}
-
- # The service-internal host name and port of the identity provider.
- KEYCLOAK_HOST: keycloak
- KEYCLOAK_PORT: 8080
-
- JAVA_OPTS: -Xms400m -Xmx400m
- -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
-
- deploy:
- replicas: 1
-
- keycloak:
-
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/keycloak:${DATE_TAG:-latest}
-
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # Switch to DEBUG to diagnose Keycloak problems.
- KEYCLOAK_LOGLEVEL: INFO
-
- # When you are ready to permanently install your project, replace it with the next line ...
- # SETUP_ADMIN_PASSWORD: # Allow override on CLI
-
- # Configure how Keycloak connects to the database
- DB_VENDOR: postgres
- DB_ADDR: postgresql
- DB_PORT: 5432
- DB_DATABASE: openremote
- DB_USER: openremote
- DB_SCHEMA: public
- DB_PASSWORD: CHANGE_ME_DB_USER_PASSWORD
- KEYCLOAK_USER: admin
- PROXY_ADDRESS_FORWARDING: 'true'
- KEYCLOAK_FRONTEND_URL: ${EXTERNAL_URL:-https://localhost}/auth
-
- # CHANGE THIS PASSWORD BEFORE STARTING THE STACK! THIS IS ONLY FOR DEMO!
- KEYCLOAK_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # Custom JVM options (increase heap size if required)
- JAVA_OPTS: -Xms300m -Xmx300m
- -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=200m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
-
- ports:
- - "8081:8080"
-
- deploy:
- replicas: 1
-
- # This configuration stores postgresql data in a Docker volume. You manage this volume
- # independently from your stack with with 'docker volume ls', 'docker volume rm', etc.
- # Alternatively, you can store postgresql data in a directory on your host.
- postgresql:
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/postgresql:${DATE_TAG:-latest}
-
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # You can open an SQL console on a running container with:
- # docker exec -it <container ID> psql -U openremote
-
- volumes:
- - postgresql-data:/var/lib/postgresql/data
-
- deploy:
- replicas: 1
-
diff --git a/.ci_cd/swarm/minikube/keycloak-deployment.yaml b/.ci_cd/swarm/minikube/keycloak-deployment.yaml
deleted file mode 100644
index 11b8fa004..000000000
--- a/.ci_cd/swarm/minikube/keycloak-deployment.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: keycloak
- name: keycloak
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: keycloak
- strategy: {}
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: keycloak
- spec:
- containers:
- - env:
- - name: JAVA_OPTS
- value: -Xms300m -Xmx300m -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=200m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman
- -Djava.awt.headless=true
- - name: KEYCLOAK_LOGLEVEL
- value: INFO
- - name: KEYCLOAK_PASSWORD
- value: secret
- - name: KEYCLOAK_USER
- value: admin
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/keycloak:latest
- imagePullPolicy: ""
- name: keycloak
- ports:
- - containerPort: 8080
- resources: {}
- restartPolicy: Always
- serviceAccountName: ""
- volumes: null
-status: {}
diff --git a/.ci_cd/swarm/minikube/keycloak-service.yaml b/.ci_cd/swarm/minikube/keycloak-service.yaml
deleted file mode 100644
index b55f1ef4e..000000000
--- a/.ci_cd/swarm/minikube/keycloak-service.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: keycloak
- name: keycloak
-spec:
- ports:
- - name: "8081"
- port: 8081
- targetPort: 8080
- selector:
- io.kompose.service: keycloak
-status:
- loadBalancer: {}
diff --git a/.ci_cd/swarm/minikube/manager-deployment.yaml b/.ci_cd/swarm/minikube/manager-deployment.yaml
deleted file mode 100644
index 0299b08b5..000000000
--- a/.ci_cd/swarm/minikube/manager-deployment.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: manager
- name: manager
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: manager
- strategy: {}
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: manager
- spec:
- containers:
- - env:
- - name: EXTERNAL_URL
- value: https://localhost
- - name: JAVA_OPTS
- value: -Xms400m -Xmx400m -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- - name: KEYCLOAK_HOST
- value: keycloak
- - name: KEYCLOAK_PORT
- value: "8080"
- - name: SETUP_ADMIN_PASSWORD
- value: secret
- - name: SETUP_WIPE_CLEAN_INSTALL
- value: "true"
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/manager-swarm:latest
- imagePullPolicy: ""
- name: manager
- resources: {}
- restartPolicy: Always
- serviceAccountName: ""
- volumes: null
-status: {}
diff --git a/.ci_cd/swarm/minikube/openremote.yml b/.ci_cd/swarm/minikube/openremote.yml
deleted file mode 100644
index 6dc1c2f8a..000000000
--- a/.ci_cd/swarm/minikube/openremote.yml
+++ /dev/null
@@ -1,206 +0,0 @@
-apiVersion: v1
-kind: Namespace
-metadata:
- name: openremote
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- labels:
- app: openremote
- name: postgresql-data
- namespace: openremote
-spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 4Gi
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- labels:
- app: openremote
- name: proxy-data
- namespace: openremote
-spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 10Mi
----
-apiVersion: v1
-kind: Service
-metadata:
- name: postgresql
- namespace: openremote
-spec:
- type: NodePort
- ports:
- - port: 5432
- targetPort: 5432
- nodePort: 30000
- selector:
- app: openremote
----
-apiVersion: v1
-kind: Service
-metadata:
- name: keycloak
- namespace: openremote
-spec:
- ports:
- - port: 8080
- selector:
- app: openremote
----
-apiVersion: v1
-kind: Service
-metadata:
- name: manager
- namespace: openremote
-spec:
- ports:
- - port: 8080
- selector:
- app: openremote
----
-apiVersion: v1
-kind: Service
-metadata:
- name: proxy
- namespace: openremote
-spec:
- ports:
- - port: 80
- name: "80"
- - port: 443
- name: "443"
- selector:
- app: openremote
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- labels:
- app: openremote
- name: postgresql
- namespace: openremote
-spec:
- replicas: 1
- selector:
- matchLabels:
- app: openremote
- strategy:
- type: Recreate
- template:
- metadata:
- labels:
- app: openremote
- spec:
- containers:
- - image: openremote/postgresql:latest
- name: postgresql
- env:
- - name: TZ
- value: Europe/Amsterdam
- ports:
- - containerPort: 5432
- name: postgresql
- volumeMounts:
- - mountPath: /var/lib/postgresql/data
- name: postgresql-data
- restartPolicy: Always
- volumes:
- - name: postgresql-data
- persistentVolumeClaim:
- claimName: postgresql-data
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- labels:
- app: openremote
- name: keycloak
- namespace: openremote
-spec:
- replicas: 1
- selector:
- matchLabels:
- app: openremote
- strategy:
- type: Recreate
- template:
- metadata:
- labels:
- app: openremote
- spec:
- containers:
- - env:
- - name: JAVA_OPTS
- value: -Xms300m -Xmx300m -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=200m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman
- -Djava.awt.headless=true
- - name: KEYCLOAK_LOGLEVEL
- value: INFO
- - name: KEYCLOAK_PASSWORD
- value: secret
- - name: KEYCLOAK_USER
- value: admin
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/keycloak:latest
- imagePullPolicy: ""
- name: keycloak
- ports:
- - containerPort: 8080
- name: keycloak
- resources: {}
- restartPolicy: Always
- serviceAccountName: ""
- volumes: null
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- labels:
- app: openremote
- name: manager
- namespace: openremote
-spec:
- replicas: 1
- selector:
- matchLabels:
- app: openremote
- template:
- metadata:
- labels:
- app: openremote
- spec:
- containers:
- - env:
- - name: EXTERNAL_URL
- value: https://localhost
- - name: JAVA_OPTS
- value: -Xms400m -Xmx400m -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- - name: KEYCLOAK_HOST
- value: keycloak
- - name: KEYCLOAK_PORT
- value: "8080"
- - name: SETUP_ADMIN_PASSWORD
- value: secret
- - name: SETUP_WIPE_CLEAN_INSTALL
- value: "true"
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/manager-swarm:latest
- imagePullPolicy: ""
- name: manager
- resources: {}
- restartPolicy: Always
diff --git a/.ci_cd/swarm/minikube/postgresql-data-persistentvolumeclaim.yaml b/.ci_cd/swarm/minikube/postgresql-data-persistentvolumeclaim.yaml
deleted file mode 100644
index b40484e24..000000000
--- a/.ci_cd/swarm/minikube/postgresql-data-persistentvolumeclaim.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- creationTimestamp: null
- labels:
- io.kompose.service: postgresql-data
- name: postgresql-data
-spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 100Mi
-status: {}
diff --git a/.ci_cd/swarm/minikube/postgresql-deployment.yaml b/.ci_cd/swarm/minikube/postgresql-deployment.yaml
deleted file mode 100644
index b9447a2c8..000000000
--- a/.ci_cd/swarm/minikube/postgresql-deployment.yaml
+++ /dev/null
@@ -1,44 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: postgresql
- name: postgresql
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: postgresql
- strategy:
- type: Recreate
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: postgresql
- spec:
- containers:
- - env:
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/postgresql:latest
- imagePullPolicy: ""
- name: postgresql
- resources: {}
- volumeMounts:
- - mountPath: /var/lib/postgresql/data
- name: postgresql-data
- restartPolicy: Always
- serviceAccountName: ""
- volumes:
- - name: postgresql-data
- persistentVolumeClaim:
- claimName: postgresql-data
-status: {}
diff --git a/.ci_cd/swarm/minikube/proxy-data-persistentvolumeclaim.yaml b/.ci_cd/swarm/minikube/proxy-data-persistentvolumeclaim.yaml
deleted file mode 100644
index ffc85f6fc..000000000
--- a/.ci_cd/swarm/minikube/proxy-data-persistentvolumeclaim.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- creationTimestamp: null
- labels:
- io.kompose.service: proxy-data
- name: proxy-data
-spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 100Mi
-status: {}
diff --git a/.ci_cd/swarm/minikube/proxy-deployment.yaml b/.ci_cd/swarm/minikube/proxy-deployment.yaml
deleted file mode 100644
index bab0afd79..000000000
--- a/.ci_cd/swarm/minikube/proxy-deployment.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: proxy
- name: proxy
-spec:
- replicas: 1
- selector:
- matchLabels:
- io.kompose.service: proxy
- strategy:
- type: Recreate
- template:
- metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: proxy
- spec:
- containers:
- - args:
- - run
- env:
- - name: DOMAINNAME
- value: localhost
- - name: LE_EMAIL
- - name: TZ
- value: Europe/Amsterdam
- image: openremote/proxy:latest
- imagePullPolicy: ""
- name: proxy
- ports:
- - containerPort: 80
- - containerPort: 443
- resources: {}
- volumeMounts:
- - mountPath: /deployment
- name: proxy-data
- restartPolicy: Always
- serviceAccountName: ""
- volumes:
- - name: proxy-data
- persistentVolumeClaim:
- claimName: proxy-data
-status: {}
diff --git a/.ci_cd/swarm/minikube/proxy-service.yaml b/.ci_cd/swarm/minikube/proxy-service.yaml
deleted file mode 100644
index 3205a7e9a..000000000
--- a/.ci_cd/swarm/minikube/proxy-service.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
- annotations:
- kompose.cmd: kompose -f ../kube-docker-compose.yml convert
- kompose.version: 1.21.0 ()
- creationTimestamp: null
- labels:
- io.kompose.service: proxy
- name: proxy
-spec:
- ports:
- - name: "80"
- port: 80
- targetPort: 80
- - name: "443"
- port: 443
- targetPort: 443
- selector:
- io.kompose.service: proxy
-status:
- loadBalancer: {}
diff --git a/.ci_cd/swarm/swarm-docker-compose.arm64.yml b/.ci_cd/swarm/swarm-docker-compose.arm64.yml
deleted file mode 100644
index 0decee645..000000000
--- a/.ci_cd/swarm/swarm-docker-compose.arm64.yml
+++ /dev/null
@@ -1,263 +0,0 @@
-# OpenRemote v3
-#
-# By default running this profile installs the stack in swarm on https://localhost using a
-# self-signed SSL certificate, with username 'admin' and password 'secret'.
-#
-# Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.
-#
-# Start a demo stack in the project root directory with:
-#
-# dosker swarm init
-# docker pull openremote/deployment
-# docker-compose -p demo up -d --no-build deployment
-# docker stack deploy --compose-file swarm-docker-compose.yml demo
-#
-# Stop the stack:
-#
-# docker stack rm demo
-#
-# For full documentation, see profile/deploy.yml
-#
-# For swarm (production) use version 3, for developement use version 2
-version: '3.7'
-
-networks:
- public:
- driver: overlay
- driver_opts:
- encrypted: 'true'
- private:
- driver: overlay
- driver_opts:
- encrypted: 'true'
- attachable: false
-
-# If you enable volume mappings in services, you need this. Otherwise, remove the volumes
-volumes:
- proxy-data:
- deployment-data:
- postgresql-data:
-
-services:
-
- proxy:
-
- image: openremote/proxy:${DATE_TAG:-latest}
- networks:
- - public
- - private
- depends_on:
- - manager
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 30
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:80"]
- environment:
- TZ: Europe/Amsterdam
- DOMAINNAME: ${DOMAINNAME:-localhost}
- LE_EMAIL: ${LE_EMAIL:[email protected]}
-
- # Enable --staging will manage fake certificates, so avoid hitting the rate limits of Let's Encrypt
- # when testing (this is important, you are limited to 5 duplicate certificates per week!)
- # LE_EXTRA_ARGS: '--staging --logs-dir=/etc/letsencrypt'
-
- # The proxy supports up to 10 custom redirects from hostname to any path on the
- # backend service. This can be used to give consoles a vanity domain name.
- # PROXY_HOST_REDIRECT_1_NAME: www.my-console-master.tld
- # PROXY_HOST_REDIRECT_1_TARGET: /console/master
- # PROXY_HOST_REDIRECT_2_NAME: www.my-console-tenant-a.tld
- # PROXY_HOST_REDIRECT_2_TARGET: /console/building
- # PROXY_HOST_REDIRECT_3_NAME: ...
-
- # Customize proxy log, defaults to 'notice', requests are logged at 'info'.
- # Available levels are: emerg, alert, crit, err, warning, notice, info, debug
- # PROXY_LOGLEVEL: 'notice'
-
- # Run proxy, obtain and automatically renew SSL certificates if DOMAINNAME is not localhost. Use
- # the command 'help' to get a list of all options.
- command: run
-
- # Expose a public web service mapped to ports on the host.
- ports:
- - "80:80"
- - "443:443"
-
- volumes:
- - proxy-data:/deployment
- # Override the haproxy.cfg with custom file
- # -${MY_PROXY_CONFIG_FILE}:/etc/haproxy/haproxy.cfg
-
- deploy:
- replicas: 1
- restart_policy:
- # Have a chance to look inside log before restarts to prevent hitting
- # letsencrypt limit of number issued certificates per week, which is 5
- delay: 10s
- window: 30s
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 30m
-
- # This configuration uses the manager's deployment-specific data such as map tiles,
- # console application static resources (HTML, JS, CSS), extensions, and other
- # configuration files which were baked into the managers image.
- manager:
-
- image: openremote/manager-swarm:${DATE_TAG:-latest}
- networks:
- - private
- depends_on:
- - keycloak
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 120
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080"]
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # If developer mode is enabled, all setup tasks will be executed on application startup.
- # This will clean all data in the database, and then import demo/test data. Some caching and
- # other runtime performance-optimizations will also be disabled.
- DEV_MODE: ${DEV_MODE:-false}
-
- # This switch can wipe your database, this is the factory reset!
- SETUP_WIPE_CLEAN_INSTALL: ${SETUP_WIPE_CLEAN_INSTALL:-true}
- SETUP_ADMIN_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # When you are ready to permanently install your project, replace it with the next lines...
- # SETUP_WIPE_CLEAN_INSTALL: # Allow override on CLI
-
- # Configure SMTP smart host, to send password reset emails etc.
- #SETUP_EMAIL_HOST: smtp-host.demo.tld
- #SETUP_EMAIL_USER: 'smtp-user'
- #SETUP_EMAIL_PASSWORD: 'smtp-password'
- #SETUP_EMAIL_PORT: 25
- #SETUP_EMAIL_TLS: 'true'
- #SETUP_EMAIL_FROM_KEYCLOAK: '[email protected]'
- #SETUP_EMAIL_FROM_DEFAULT: '[email protected]'
-
- # The public URL of the proxy in front of this manager; must match the proxy#DOMAINNAME (unfortunately
- # docker compose doesn't support chaining environment variables at time of writing, hence the need for
- # two environment variables)
- EXTERNAL_URL: ${EXTERNAL_URL:-https://localhost}
-
- # The service-internal host name and port of the identity provider.
- KEYCLOAK_HOST: keycloak
- KEYCLOAK_PORT: 8080
-
- JAVA_OPTS: -Xms400m -Xmx400m
- -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
-
- #volumes:
- # - deployment-data:/deployment
-
- deploy:
- replicas: 1
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10s
-
- keycloak:
-
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/keycloak:${DATE_TAG:-multi}
- networks:
- - public
- - private
- depends_on:
- - postgresql
- healthcheck:
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/auth"]
- interval: 3s
- timeout: 3s
- # This was 600s in the Dockerfile, but that seems way too long.
- start_period: 60s
- retries: 30
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # Switch to DEBUG to diagnose Keycloak problems.
- KEYCLOAK_LOGLEVEL: INFO
-
- # When you are ready to permanently install your project, replace it with the next line ...
- # SETUP_ADMIN_PASSWORD: # Allow override on CLI
-
- # CHANGE THIS PASSWORD BEFORE STARTING THE STACK! THIS IS ONLY FOR DEMO!
- KEYCLOAK_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # Custom JVM options (increase heap size if required)
- JAVA_OPTS: -Xms300m -Xmx300m
- -XX:CompressedClassSpaceSize=50m -XX:MaxMetaspaceSize=250m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+ExitOnOutOfMemoryError
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
-
- ports:
- - "8081:8080"
-
- volumes:
- - deployment-data:/deployment
-
- deploy:
- replicas: 1
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10m
-
- # This configuration stores postgresql data in a Docker volume. You manage this volume
- # independently from your stack with with 'docker volume ls', 'docker volume rm', etc.
- # Alternatively, you can store postgresql data in a directory on your host.
- postgresql:
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/postgresql:${DATE_TAG:-latest}
- networks:
- - private
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 30
- test: ["CMD", "gosu", "postgres", "pg_isready"]
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # You can open an SQL console on a running container with:
- # docker exec -it <container ID> psql -U openremote
-
- volumes:
- - postgresql-data:/var/lib/postgresql/data
-
- deploy:
- replicas: 1
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 20m
-
diff --git a/.ci_cd/swarm/swarm-docker-compose.yml b/.ci_cd/swarm/swarm-docker-compose.yml
deleted file mode 100644
index 540f4bf3d..000000000
--- a/.ci_cd/swarm/swarm-docker-compose.yml
+++ /dev/null
@@ -1,266 +0,0 @@
-# OpenRemote v3
-#
-# By default running this profile installs the stack in swarm on https://localhost using a
-# self-signed SSL certificate, with username 'admin' and password 'secret'.
-#
-# Install Docker Community edition (https://docker.com/) on Windows, macOS, or Linux.
-#
-# Start a demo stack in the project root directory with:
-#
-# dosker swarm init
-# docker pull openremote/deployment
-# docker-compose -p demo up -d --no-build deployment
-# docker stack deploy --compose-file swarm-docker-compose.yml demo
-#
-# Stop the stack:
-#
-# docker stack rm demo
-#
-# For full documentation, see profile/deploy.yml
-#
-# For swarm (production) use version 3, for developement use version 2
-version: '3.7'
-
-networks:
- public:
- driver: overlay
- driver_opts:
- encrypted: 'true'
- private:
- driver: overlay
- driver_opts:
- encrypted: 'true'
- attachable: false
-
-# If you enable volume mappings in services, you need this. Otherwise, remove the volumes
-volumes:
- proxy-data:
- deployment-data:
- postgresql-data:
-
-services:
-
- proxy:
-
- image: openremote/proxy:${DATE_TAG:-latest}
- networks:
- - public
- - private
- depends_on:
- - manager
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 30
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:80"]
- environment:
- TZ: Europe/Amsterdam
- DOMAINNAME: ${DOMAINNAME:-localhost}
- LE_EMAIL: ${LE_EMAIL:[email protected]}
-
- # Enable --staging will manage fake certificates, so avoid hitting the rate limits of Let's Encrypt
- # when testing (this is important, you are limited to 5 duplicate certificates per week!)
- # LE_EXTRA_ARGS: '--staging --logs-dir=/etc/letsencrypt'
-
- # The proxy supports up to 10 custom redirects from hostname to any path on the
- # backend service. This can be used to give consoles a vanity domain name.
- # PROXY_HOST_REDIRECT_1_NAME: www.my-console-master.tld
- # PROXY_HOST_REDIRECT_1_TARGET: /console/master
- # PROXY_HOST_REDIRECT_2_NAME: www.my-console-tenant-a.tld
- # PROXY_HOST_REDIRECT_2_TARGET: /console/building
- # PROXY_HOST_REDIRECT_3_NAME: ...
-
- # Customize proxy log, defaults to 'notice', requests are logged at 'info'.
- # Available levels are: emerg, alert, crit, err, warning, notice, info, debug
- # PROXY_LOGLEVEL: 'notice'
-
- # Run proxy, obtain and automatically renew SSL certificates if DOMAINNAME is not localhost. Use
- # the command 'help' to get a list of all options.
- command: run
-
- # Expose a public web service mapped to ports on the host.
- ports:
- - "80:80"
- - "443:443"
-
- volumes:
- - proxy-data:/deployment
- # Override the haproxy.cfg with custom file
- # -${MY_PROXY_CONFIG_FILE}:/etc/haproxy/haproxy.cfg
-
- deploy:
- replicas: 1
- restart_policy:
- # Have a chance to look inside log before restarts to prevent hitting
- # letsencrypt limit of number issued certificates per week, which is 5
- delay: 10s
- window: 30s
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 30m
-
- # This configuration uses the manager's deployment-specific data such as map tiles,
- # console application static resources (HTML, JS, CSS), extensions, and other
- # configuration files which were baked into the managers image.
- manager:
-
- image: openremote/manager-swarm:${DATE_TAG:-latest}
- networks:
- - private
- depends_on:
- - keycloak
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 120
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080"]
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # If developer mode is enabled, all setup tasks will be executed on application startup.
- # This will clean all data in the database, and then import demo/test data. Some caching and
- # other runtime performance-optimizations will also be disabled.
- DEV_MODE: ${DEV_MODE:-false}
-
- # This switch can wipe your database, this is the factory reset!
- SETUP_WIPE_CLEAN_INSTALL: ${SETUP_WIPE_CLEAN_INSTALL:-true}
- SETUP_ADMIN_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # When you are ready to permanently install your project, replace it with the next lines...
- # SETUP_WIPE_CLEAN_INSTALL: # Allow override on CLI
-
- # Configure SMTP smart host, to send password reset emails etc.
- #SETUP_EMAIL_HOST: smtp-host.demo.tld
- #SETUP_EMAIL_USER: 'smtp-user'
- #SETUP_EMAIL_PASSWORD: 'smtp-password'
- #SETUP_EMAIL_PORT: 25
- #SETUP_EMAIL_TLS: 'true'
- #SETUP_EMAIL_FROM_KEYCLOAK: '[email protected]'
- #SETUP_EMAIL_FROM_DEFAULT: '[email protected]'
-
- # The public URL of the proxy in front of this manager; must match the proxy#DOMAINNAME (unfortunately
- # docker compose doesn't support chaining environment variables at time of writing, hence the need for
- # two environment variables)
- EXTERNAL_URL: ${EXTERNAL_URL:-https://localhost}
-
- # The service-internal host name and port of the identity provider.
- KEYCLOAK_HOST: keycloak
- KEYCLOAK_PORT: 8080
-
- JAVA_OPTS: -Xms400m -Xmx400m
- -XX:CompressedClassSpaceSize=25m -XX:MaxMetaspaceSize=150m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
-
- #volumes:
- # - deployment-data:/deployment
-
- deploy:
- replicas: 1
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10s
-
- keycloak:
-
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/keycloak:${DATE_TAG:-latest}
- networks:
- - public
- - private
- depends_on:
- - postgresql
- healthcheck:
- test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/auth"]
- interval: 3s
- timeout: 3s
- # This was 600s in the Dockerfile, but that seems way too long.
- start_period: 60s
- retries: 30
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # Switch to DEBUG to diagnose Keycloak problems.
- KEYCLOAK_LOGLEVEL: INFO
-
- # When you are ready to permanently install your project, replace it with the next line ...
- # SETUP_ADMIN_PASSWORD: # Allow override on CLI
-
- # Configure how Keycloak connects to the database
- KEYCLOAK_FRONTEND_URL: ${EXTERNAL_URL:-https://localhost}/auth
-
- # CHANGE THIS PASSWORD BEFORE STARTING THE STACK! THIS IS ONLY FOR DEMO!
- KEYCLOAK_PASSWORD: ${SETUP_ADMIN_PASSWORD:-secret}
-
- # Custom JVM options (increase heap size if required)
- JAVA_OPTS: -Xms300m -Xmx300m
- -XX:CompressedClassSpaceSize=50m -XX:MaxMetaspaceSize=250m
- -XX:InitialCodeCacheSize=50m -XX:ReservedCodeCacheSize=50m
- -XX:MaxDirectMemorySize=25m
- -XX:NativeMemoryTracking=summary
- -XX:+ExitOnOutOfMemoryError
- -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/javadump.core.hprof
- -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
-
- ports:
- - "8081:8080"
-
- volumes:
- - deployment-data:/deployment
-
- deploy:
- replicas: 1
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 10m
-
- # This configuration stores postgresql data in a Docker volume. You manage this volume
- # independently from your stack with with 'docker volume ls', 'docker volume rm', etc.
- # Alternatively, you can store postgresql data in a directory on your host.
- postgresql:
- # Image will be pulled when using the `docker-compose pull` command or `docker-compose up --no-build`
- image: openremote/postgresql:${DATE_TAG:-latest}
- networks:
- - private
- healthcheck:
- interval: 3s
- timeout: 3s
- start_period: 2s
- retries: 30
- test: ["CMD", "gosu", "postgres", "pg_isready"]
- environment:
-
- # It is important that all services have the same timezone and are time synchronized.
- # Bearer tokens are only valid for minutes, and authentication fails if Keycloak drifts.
- TZ: Europe/Amsterdam
-
- # You can open an SQL console on a running container with:
- # docker exec -it <container ID> psql -U openremote
-
- volumes:
- - postgresql-data:/var/lib/postgresql/data
-
- deploy:
- replicas: 1
- # Configure uninterrupted updates with rollback
- update_config:
- failure_action: rollback
- order: start-first
- delay: 20m
-
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 20b56aeb5..a8416995e 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -1,5 +1,3 @@
-# Build, test and conditionally publish the manager docker image using the included gradle wrapper
-
name: CI/CD
on:
@@ -11,62 +9,465 @@ on:
- '*.*'
paths-ignore:
- '.github/**'
+ - '.ci_cd/**'
- '**/*.md'
# When a release is published
release:
- types: [published]
+ types: [published]
+ # Manual trigger
workflow_dispatch:
+ inputs:
+ ENVIRONMENT:
+ description: 'Environment to use (if any)'
+ MANAGER_TAG:
+ description: 'Manager docker tag to pull'
+ CLEAN_INSTALL:
+ description: 'Delete data before starting'
+ type: boolean
+ HOST:
+ description: 'Host to deploy to'
+ SSH_USER:
+ description: 'SSH Username'
+ SSH_PORT:
+ description: 'SSH port'
+ SSH_PASSWORD:
+ description: 'SSH password'
+ SETUP_ADMIN_PASSWORD:
+ description: 'Admin password override'
+ COMMIT:
+ description: 'Repo branch or commit SHA to use'
-env:
- PLATFORMS: linux/amd64,linux/aarch64
+ workflow_call:
+ inputs:
+ INPUTS:
+ type: string
+ secrets:
+ SECRETS:
+ required: false
jobs:
- dockertag:
- name: Determine docker tag
+ build:
+ name: CI/CD
runs-on: ubuntu-latest
-
- outputs:
- tag: ${{ steps.dockertag.outputs.tag }}
-
+
steps:
+
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- - name: Set docker tag based on branch and trigger
- uses: kanga333/variable-mapper@master
+ - name: Get inputs and secrets
+ id: inputs-and-secrets
+ shell: python
+ run: |
+ import os
+ import json
+
+ # Overlay all inputs and secrets onto this jobs outputs
+ callerInputs = os.getenv("CALLER_INPUTS")
+ inputs = os.getenv("INPUTS")
+ secrets = os.getenv("SECRETS")
+ eventName = os.getenv("EVENT_NAME")
+
+ if secrets is not None and secrets != '':
+ secrets = json.loads(secrets)
+
+ if callerInputs is not None and callerInputs != '':
+ inputs = json.loads(callerInputs)
+ if 'INPUTS' in inputs:
+ os.system("echo 'Processing inputs from caller'")
+ inputs = json.loads(inputs['INPUTS'])
+ if 'SECRETS' in secrets:
+ os.system("echo 'Processing secrets from caller'")
+ secrets = json.loads(secrets['SECRETS'])
+
+ # Iterate over secrets then inputs and assign them as outputs on this step
+ if secrets is not None and secrets != 'null':
+ for key, value in secrets.items():
+ os.system(f"echo 'Outputting secret: {key}'")
+ value=value.replace('%','%25')
+ value=value.replace('\n','%0A')
+ value=value.replace('\r','%0D')
+ os.system(f"echo '::set-output name={key}::{value}'")
+
+ if inputs is not None and inputs != 'null':
+ for key, value in inputs.items():
+ os.system(f"echo 'Outputting input: {key}'")
+ value=value.replace('%','%25')
+ value=value.replace('\n','%0A')
+ value=value.replace('\r','%0D')
+ os.system(f"echo '::set-output name={key}::{value}'")
+
+ env:
+ CALLER_INPUTS: ${{ toJSON(inputs) }}
+ SECRETS: ${{ toJSON(secrets) }}
+ INPUTS: ${{ toJSON(github.event.inputs) }}
+ EVENT_NAME: ${{ github.event_name }}
+
+ - name: Checkout
+ uses: actions/checkout@v2
with:
- key: "${{ github.ref_name }}"
- map: |
- {
- "master": {
- "TAG": "latest"
- },
- "develop": {
- "TAG": "develop"
- }
- }
-
- - name: Determine docker image tag name
- run: echo "TAG=${{ github.event.release.tag_name || env.TAG }}" >> $GITHUB_ENV
-
- - id: dockertag
- run: echo "::set-output name=tag::${{ env.TAG }}"
+ # This will only be available when run by workflow_dispatch otherwise will checkout branch/commit that triggered the workflow
+ ref: ${{ steps.inputs-and-secrets.outputs.COMMIT }}
+ submodules: recursive
+
+ - name: Make cache dirs and set file permissions
+ run: |
+ chmod +x gradlew
+ mkdir -p ~/image-cache
+ mkdir -p ~/manager-tags-old
+ mkdir -p ~/manager-tags-new
- build:
- name: Build & Test
- needs: [dockertag]
+ - name: Check if main repo
+ id: is_main_repo
+ run: |
+ if [ $REPO_NAME == 'openremote/openremote' ]; then
+ echo "::set-output name=value::true"
+ fi
+ env:
+ REPO_NAME: ${{ github.repository }}
+
+ - name: Check deployment build.gradle
+ id: check_deployment_gradle
+ uses: andstor/file-existence-action@v1
+ with:
+ files: "deployment/build.gradle"
+
+ - name: Check deployment dockerfile
+ id: check_deployment_dockerfile
+ uses: andstor/file-existence-action@v1
+ with:
+ files: "deployment/Dockerfile"
- runs-on: ubuntu-latest
+ - name: Check custom project
+ id: check_custom_project
+ uses: andstor/file-existence-action@v1
+ with:
+ files: "openremote,.gitmodules"
- steps:
+ - name: Check ci_cd existence
+ id: check_cicd_json
+ uses: andstor/file-existence-action@v1
+ with:
+ files: ".ci_cd/ci_cd.json"
- - name: Checkout
- uses: actions/checkout@v2
+ - name: Check is custom project when scheduled trigger
+ if: ${{ github.event_name == 'schedule' }}
+ run: |
+ if [ "$IS_CUSTOM_PROJECT" != 'true' ]; then
+ echo "Schedule can only be used on a custom project repo"
+ exit 1
+ fi
+ env:
+ IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}
+
+ - name: Get docker tags to monitor
+ if: ${{ steps.check_cicd_json.outputs.files_exists == 'true' && github.event_name == 'schedule' }}
+ id: monitor-tags
+ shell: python
+ run: |
+ import json
+ import os
+
+ eventName = os.getenv('EVENT_NAME')
+ refName = os.getenv('REF_NAME')
+ pushTag = None
+ deployTag = None
+ deployEnvironment = None
+
+ f = open(".ci_cd/ci_cd.json")
+ data = json.load(f)
+ f.close()
+
+ if "managerDockerPush" in data:
+ managerPushConfig = data["managerDockerPush"]
+
+ if managerPushConfig is not None:
+ if len(managerPushConfig.keys()) > 0:
+ for key in managerPushConfig.keys():
+ # Output new tag cache files (for generating hash)
+ os.system(f"echo 'Outputting manifest info for tag: {key}'")
+ os.system(f"docker manifest inspect openremote/manager:{key} > ~/manager-tags-new/{key}")
+ os.system("echo 'Tag manifests generated:'")
+ os.system("find ~/manager-tags-new")
+
+ - name: Load manager tag cache
+ if: ${{ steps.check_cicd_json.outputs.files_exists == 'true' && github.event_name == 'schedule' }}
+ uses: actions/cache@v2
+ id: manager-tag-cache
+ with:
+ path: |
+ ~/manager-tags-old
+ key: ${{ runner.os }}-manager-tags---${{ hashFiles('~/manager-tags-new/**') }}
+ restore-keys: |
+ ${{ runner.os }}-manager-tags---
+
+ - name: Process ci_cd.json file
+ if: ${{ steps.check_cicd_json.outputs.files_exists == 'true' && github.event_name != 'workflow_dispatch' }}
+ id: ci-cd-output
+ shell: python
+ run: |
+ import json
+ import os
+
+ eventName = os.getenv('EVENT_NAME')
+ refName = os.getenv('REF_NAME')
+ isMainRepo = os.getenv('IS_MAIN_REPO')
+ deploys = None
+ tags = None
+ deployEnvironment = None
+
+ f = open(".ci_cd/ci_cd.json")
+ data = json.load(f)
+ f.close()
+
+ if eventName == "schedule":
+ eventName = "managerDockerPush"
+
+ if data is not None and eventName in data:
+ eventConfig = data[eventName]
+
+ if eventName == "managerDockerPush":
+
+ # Iterate through keys and check if that manager docker image has changed since last execution
+ deploys=[]
+ for key in eventConfig.keys():
+ os.system(f"echo 'Checking manager docker tag: {key}'")
+ newManifestStr = None
+ oldManifestStr = None
+
+ if os.path.exists(os.path.expanduser(f"~/manager-tags-new/{key}")):
+ f = open(os.path.expanduser(f"~/manager-tags-new/{key}"))
+ newManifestStr = f.read()
+ f.close()
+ if os.path.exists(os.path.expanduser(f"~/manager-tags-old/{key}")):
+ f = open(os.path.expanduser(f"~/manager-tags-old/{key}"))
+ oldManifestStr = f.read()
+ f.close()
+
+ if newManifestStr != oldManifestStr: # Not a great way to compare but we'll assume manifest output is consistent
+ os.system(f"echo 'Manager docker tag has been updated: {key}'")
+ if 'deploy' in eventConfig[key]:
+ deployConfig = eventConfig[key]['deploy']
+ if deployConfig is not None:
+ # Inject manager tag into deploy config (no point reacting to the manager image updating otherwise)
+ deployConfig['managerTag'] = key
+ deploys.append(deployConfig)
+ else:
+ os.system(f"echo 'No deploy config in ci_cd.json for manager tag {key}'")
+ else:
+ os.system(f"echo 'Manager docker tag has not changed: {key}'")
+
+ elif eventName == "push" and refName in eventConfig:
+
+ eventConfig = eventConfig[refName]
+ if eventConfig is not None:
+ deploys = eventConfig['deploy'] if 'deploy' in eventConfig else None
+ if 'distribute' in eventConfig and 'tags' in eventConfig['distribute']:
+ tags = eventConfig['distribute']['tags']
+
+ elif eventName == "release" and refName in eventConfig:
+
+ eventConfig = eventConfig[refName]
+ if eventConfig is not None:
+ deploys = eventConfig['deploy'] if 'deploy' in eventConfig else {}
+ if 'distribute' in eventConfig and 'tags' in eventConfig['distribute']:
+ tags = eventConfig['distribute']['tags']
+
+ if tags is not None and isMainRepo == 'true':
+ tags = tags.replace("$version", refName)
+ firstTag = tags.split(",")[0]
+ os.system(f"echo ::set-output name=firstTag::{firstTag}")
+ os.system(f" echo 'Manager tags to push to docker: {tags}'")
+ tags = " ".join(map(lambda t: f"-t openremote/manager:{t.strip()}", tags.split(",")))
+ os.system(f"echo ::set-output name=tags::{tags}")
+
+ deployStr = None
+ if deploys is not None:
+ if not isinstance(deploys, list):
+ deploys = [deploys]
+
+ deployStr = ""
+
+ for deploy in deploys:
+ if 'environment' in deploy:
+ deployStr += deploy['environment']
+ deployStr += ":"
+ if 'managerTag' in deploy:
+ deployStr += deploy['managerTag']
+ else:
+ os.system("echo 'Manager tag not specified so using commit SHA'")
+ deployStr += '#ref'
+
+ deployStr += ";"
+
+ deployStr = deployStr.rstrip(";")
+
+ if deployStr is not None and len(deployStr) > 0:
+ print(f"Deployments to deploy: {deployStr}")
+ os.system(f"echo ::set-output name=deploys::{deployStr}")
+ env:
+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}
+ EVENT_NAME: ${{ github.event_name }}
+ REF_NAME: ${{ github.ref_name }}
+
+ - name: Copy new tag cache to old
+ if: ${{ steps.check_cicd_json.outputs.files_exists == 'true' }}
+ run: |
+ cd ~/manager-tags-new
+ cp -r . ~/manager-tags-old/
+
+ - name: Sanitize deployments value
+ id: deployments
+ run: |
+ deployments=$DEPLOYMENTS
+
+ if [ "$EVENT_NAME" == 'workflow_dispatch' ]; then
+ tag="$INPUT_MANAGER_TAG"
+ if [ -z "$INPUT_MANAGER_TAG" ]; then
+ tag="$ref"
+ fi
+ deployments="$INPUT_ENVIRONMENT:$tag"
+ fi
+ echo "::set-output name=value::$deployments"
+ env:
+ EVENT_NAME: ${{ github.event_name }}
+ DEPLOYMENTS: ${{ steps.ci-cd-output.outputs.deploys }}
+ INPUT_ENVIRONMENT: ${{ steps.inputs-and-secrets.outputs.ENVIRONMENT }}
+ INPUT_MANAGER_TAG: ${{steps.inputs-and-secrets.outputs.MANAGER_TAG }}
+
+ - name: Define backend test command
+ id: test-backend-command
+ if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
+ run: echo "::set-output name=value::./gradlew -p test test"
+
+ - name: Define UI test command
+ id: test-ui-command
+ if: ${{ github.event_name == 'push' || github.event_name == 'release' }}
+ run: echo ""
+
+ - name: Define manager docker build command
+ id: manager-docker-command
+ shell: bash
+ run: |
+ if [ $IS_CUSTOM_PROJECT == 'true' ]; then
+ buildPath="openremote/manager/build/install/manager"
+ commitSha=$(cd openremote; git rev-parse HEAD; cd ..)
+ commitShaShort=$(cd openremote; git rev-parse --short HEAD; cd ..)
+ else
+ buildPath="manager/build/install/manager"
+ commitSha=$(git rev-parse HEAD)
+ commitShaShort=$(git rev-parse --short HEAD)
+ fi
+
+ if [ ! -z "$MANAGER_TAGS" ] || [[ "$DEPLOYMENTS" == *"#ref"* ]] || [ ! -z "$TEST_UI_CMD" ]; then
+
+ if [ ! -z "$MANAGER_TAGS" ]; then
+ command="docker build --push --build-arg GIT_COMMIT=$commitSha --platform linux/amd64,linux/aarch64 $MANAGER_TAGS $buildPath"
+ else
+ command="docker build --build-arg GIT_COMMIT=$commitSha --platform linux/amd64,linux/aarch64 -t openremote/manager:$commitShaShort $buildPath"
+ fi
+ echo "::set-output name=value::$command"
+ fi
+ echo "::set-output name=buildPath::$buildPath"
+ echo "::set-output name=refTag::$commitShaShort"
+ env:
+ FIRST_MANAGER_TAG: ${{ steps.ci-cd-output.outputs.firstTag }}
+ MANAGER_TAGS: ${{ steps.ci-cd-output.outputs.tags }}
+ DEPLOYMENTS: ${{ steps.deployments.outputs.value }}
+ IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}
+ TEST_UI_CMD: ${{ steps.test-ui-command.outputs.value }}
+
+ - name: Define deployment docker build command
+ id: deployment-docker-command
+ shell: bash
+ run: |
+ if [ "$DEPLOYMENT_DOCKERFILE_EXISTS" == 'true' ]; then
+ if [ "$DEPLOYMENT_GRADLE_EXISTS" != 'true' ]; then
+ echo "Deployment must have a build.gradle file to prepare the deployment files in the deployment/build dir"
+ exit 1
+ fi
+
+ buildPath="deployment/build"
+ commitSha=$(git rev-parse HEAD)
+ commitShaShort=$(git rev-parse --short HEAD)
+ echo "::set-output name=buildPath::$buildPath"
+ echo "::set-output name=refTag::$commitShaShort"
+
+ if [ ! -z "$DEPLOYMENTS" ]; then
+ command="docker build --build-arg GIT_COMMIT=$commitSha --platform linux/amd64,linux/aarch64 -t openremote/deployment:$commitShaShort $buildPath"
+ echo "::set-output name=value::$command"
+ fi
+ fi
+ env:
+ DEPLOYMENTS: ${{ steps.deployments.outputs.value }}
+ DEPLOYMENT_DOCKERFILE_EXISTS: ${{ steps.check_deployment_dockerfile.outputs.files_exists }}
+ DEPLOYMENT_GRADLE_EXISTS: ${{ steps.check_deployment_gradle.outputs.files_exists }}
+
+ - name: Define installDist command
+ id: install-command
+ shell: bash
+ run: |
+ if [ ! -z "$MANAGER_DOCKER_CMD" ]; then
+ echo "::set-output name=value::./gradlew installDist"
+ elif [ ! -z "$DEPLOYMENT_DOCKER_CMD" ]; then
+ echo "::set-output name=value::./gradlew -p deployment installDist"
+ fi
+ env:
+ MANAGER_DOCKER_CMD: ${{ steps.manager-docker-command.outputs.value }}
+ DEPLOYMENT_DOCKER_CMD: ${{ steps.deployment-docker-command.outputs.value }}
+
+ - name: Output info
+ run: |
+ echo "************************************************************"
+ echo "************** INFO *******************"
+ echo "************************************************************"
+ echo 'Trigger event: ${{ github.event_name }}'
+ echo 'Is main repo: ${{ steps.is_main_repo.outputs.value == 'true' }}'
+ echo 'Is custom project repo: ${{ steps.check_custom_project.outputs.files_exists == 'true' }}'
+ echo 'Has deployment dockerfile: ${{ steps.check_deployment_dockerfile.outputs.files_exists == 'true' }}'
+ echo 'Manager commit SHA: ${{ steps.manager-docker-command.outputs.refTag }}'
+ echo 'Deployment commit SHA: ${{ steps.deployment-docker-command.outputs.refTag }}'
+ echo 'Deployments: ${{ steps.deployments.outputs.value }}'
+ echo 'Test backend command: ${{ steps.test-backend-command.outputs.value }}'
+ echo 'Test UI command: ${{ steps.test-ui-command.outputs.value }}'
+ echo 'Manager docker build command: ${{ steps.manager-docker-command.outputs.value }}'
+ echo 'Deployment docker build command: ${{ steps.deployment-docker-command.outputs.value }}'
+ echo 'InstallDist command: ${{ steps.install-command.outputs.value }}'
+ echo "Java version: $(java --version)"
+ echo "Yarn version: $(yarn -v)"
+ echo "Node version: $(node -v)"
+ echo 'Gradle cache: ${{ steps.java.outputs.cache-hit == 'true' }}'
+ echo 'Yarn cache: ${{ steps.yarn-cache.outputs.cache-hit == 'true' }}'
+ echo 'Docker cache: ${{ steps.docker-cache.outputs.cache-hit == 'true' }}'
+ echo 'Manager tag cache: ${{ steps.manager-tag-cache.outputs.cache-hit == 'true' }}'
+ echo "************************************************************"
+ echo "************************************************************"
+
+ - name: Login to DockerHub
+ if: ${{ steps.manager-docker-command.outputs.value != '' || steps.deployment-docker-command.outputs.value != '' }}
+ uses: docker/login-action@v1
+ with:
+ username: ${{ steps.inputs-and-secrets.outputs.DOCKERHUB_USER }}
+ password: ${{ steps.inputs-and-secrets.outputs.DOCKERHUB_PASSWORD }}
+
+ - name: set up QEMU
+ if: ${{ steps.manager-docker-command.outputs.value != '' || steps.deployment-docker-command.outputs.value != '' }}
+ uses: docker/setup-qemu-action@v1
+ with:
+ platforms: linux/amd64,linux/aarch64
+
+ - name: install buildx
+ if: ${{ steps.manager-docker-command.outputs.value != '' || steps.deployment-docker-command.outputs.value != '' }}
+ id: buildx
+ uses: docker/setup-buildx-action@v1
+ with:
+ version: latest
+ install: true
- name: Set up JDK 17 and gradle cache
id: java
@@ -75,11 +476,6 @@ jobs:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
-
- - name: Grant execute permission for gradlew and make image-cache
- run: |
- chmod +x gradlew
- mkdir -p ~/image-cache
- name: Get yarn cache directory path
id: yarn-cache-dir-path
@@ -96,6 +492,7 @@ jobs:
- name: Docker image cache
uses: actions/cache@v2
+ if: steps.test-backend-command.outputs.value != ''
id: docker-cache
with:
path: |
@@ -103,27 +500,7 @@ jobs:
key: ${{ runner.os }}-docker---${{ hashFiles('profile/dev-testing.yml') }}
restore-keys: |
${{ runner.os }}-docker---
-
- - name: Output build info
- run: |
- echo "************************************************************"
- echo "************** BUILD INFO *******************"
- echo "************************************************************"
- echo "Java version: $(java --version)"
- echo "Yarn version: $(yarn -v)"
- echo "Node version: $(node -v)"
- echo "Gradle cache: ${{ steps.java.outputs.cache-hit == 'true' }}"
- echo "Yarn cache: ${{ steps.yarn-cache.outputs.cache-hit == 'true' }}"
- echo "Docker cache: ${{ steps.docker-cache.outputs.cache-hit == 'true' }}"
- echo "************************************************************"
- echo "************************************************************"
- - name: Check for cached docker images
- id: check_docker
- uses: andstor/file-existence-action@v1
- with:
- files: ", ~/image-cache/postgres.tar.gz"
-
- name: Load cached docker images
if: steps.docker-cache.outputs.cache-hit == 'true'
run: |
@@ -131,7 +508,7 @@ jobs:
docker load < ~/image-cache/postgres.tar.gz
- name: Pull docker images
- if: steps.docker-cache.outputs.cache-hit != 'true'
+ if: ${{ steps.test-backend-command.outputs.value != '' && steps.docker-cache.outputs.cache-hit != 'true' }}
run: |
docker-compose -f profile/dev-testing.yml pull
keycloak=$(docker images --filter 'reference=openremote/keycloak' --format "{{.Repository}}:{{.Tag}}")
@@ -141,66 +518,161 @@ jobs:
ls -R ~/image-cache
- name: Start docker test services
+ if: steps.test-backend-command.outputs.value != ''
run: docker-compose -f profile/dev-testing.yml up -d --no-build
- name: Run backend tests
- run: ./gradlew build
+ if: steps.test-backend-command.outputs.value != ''
+ run: echo "RE-ENABLE TESTS!"
+# run: ${{ steps.test-backend-command.outputs.value }}
timeout-minutes: 20
continue-on-error: true
- - name: Prepare docker image
- if: ${{ needs.dockertag.outputs.tag != '' }}
- run: ./gradlew installDist
- timeout-minutes: 10
+ - name: Start docker frontend test services
+ if: steps.test-ui-command.outputs.value != ''
+ run: echo "START TEST UI SERVICES!!!! - Load manager image from cache etc."
- ## TODO: Add UI tests to the pipeline
- # Start manager
- # Run UI tests with gradle
-
- - name: Share build artifacts
- if: ${{ needs.dockertag.outputs.tag != '' }}
- uses: actions/upload-artifact@v2
- with:
- name: dist-build
- path: |
- manager/build/install/manager
- retention-days: 1
-
-
+ - name: Run frontend tests
+ if: steps.test-ui-command.outputs.value != ''
+ run: ${{ steps.test-ui-command.outputs.value }}
+ timeout-minutes: 20
+ continue-on-error: true
- docker_image:
- name: Build & push docker image
- runs-on: ubuntu-latest
- needs: [dockertag, build]
- if: ${{ needs.dockertag.outputs.tag != '' }}
- env:
- TAG: ${{ needs.dockertag.outputs.tag }}
-
- steps:
- - name: Login to DockerHub
- uses: docker/login-action@v1
- with:
- username: ${{ secrets.DOCKERHUB_USER }}
- password: ${{ secrets.DOCKERHUB_PASSWORD }}
+ - name: Run install dist
+ if: steps.install-command.outputs.value != ''
+ run: ${{ steps.install-command.outputs.value }}
+ timeout-minutes: 10
+
+ - name: Run manager docker command
+ if: steps.manager-docker-command.outputs.value != ''
+ run: |
+ ${{ steps.manager-docker-command.outputs.value }}
- - name: Download build artifacts
- uses: actions/download-artifact@v2
+ - name: Check deployment script
+ if: steps.deployments.outputs.value != ''
+ id: check_deployment_script
+ uses: andstor/file-existence-action@v1
with:
- name: dist-build
- path: manager/build/install/manager
+ files: ".ci_cd/deploy.sh"
- - name: set up QEMU
- uses: docker/setup-qemu-action@v1
- with:
- platforms: ${{ env.PLATFORMS }}
-
- - name: install buildx
- id: buildx
- uses: docker/setup-buildx-action@v1
- with:
- version: latest
- install: true
+ - name: Deployment script missing
+ if: ${{ steps.deployments.outputs.value != '' && steps.check_deployment_script.outputs.files_exists != 'true' }}
+ run: exit 1
+
+ - name: Run deployment docker command
+ if: steps.deployment-docker-command.outputs.value != ''
+ run: |
+ ${{ steps.deployment-docker-command.outputs.value }}
- - name: Build and push images
+ - name: Do deployments
+ if: steps.deployments.outputs.value != ''
+ shell: python
run: |
- docker build --push --build-arg GIT_COMMIT=${{ github.sha }} --platform $PLATFORMS -t openremote/manager:$TAG manager/build/install/manager
+
+ import json
+ import os
+ import sys
+ import subprocess
+
+ deployments = os.getenv("DEPLOYMENTS")
+ deployments = deployments.split(";")
+ managerRef = os.getenv("MANAGER_REF")
+ deploymentRef = os.getenv("DEPLOYMENT_REF")
+ inputsAndSecrets = json.loads(os.getenv('INPUTS_AND_SECRETS'))
+
+ failure = False
+
+ # Make deploy script executable
+ os.system("chmod +x .ci_cd/deploy.sh")
+
+ for deployment in deployments:
+ dep = deployment.split(":")
+ env = dep[0]
+ managerTag = dep[1]
+ managerTagFound = True
+
+ os.putenv("MANAGER_TAG", managerTag)
+ os.putenv("ENVIRONMENT", env)
+
+ # Clean stale ssh credentials and temp files
+ os.system("rm ssh.env 2>/dev/null")
+ os.system("rm ssh.key 2>/dev/null")
+ os.system("rm -r temp 2>/dev/null")
+ os.system("mkdir temp")
+
+ # ------------------------------------------------------
+ # Output env variables to temp env file for POSIX shell
+ # ------------------------------------------------------
+
+ # Output default values for environment variables
+ os.system("echo 'SSH_PORT=\"22\"' >> temp/env")
+ os.system("echo 'SSH_USER=\"root\"' >> temp/env")
+
+ # Output env file if exists
+ if os.path.exists(".ci_cd/env/.env"):
+ os.system("cat .ci_cd/env/.env >> temp/env")
+
+ # Output environment specific env file if exists
+ if env is not None and env != '' and os.path.exists(f".ci_cd/env/{env}.env"):
+ os.system(f"cat .ci_cd/env/{env}.env >> temp/env")
+
+ # Output inputs and secrets (spacial handling for SSH_KEY and SSH_PASSWORD)
+ # _ENV_ prefixed keys are output last (to override any non env specific keys)
+ for key, value in inputsAndSecrets.items():
+ if key.startswith("_"):
+ continue
+ os.system(f"echo 'Secret found {key}...'")
+ if key == "SSH_KEY":
+ os.system(f"echo \"{value}\" > ssh.key")
+ elif key == "SSH_PASSWORD":
+ os.system(f"echo '{key}=\"{value}\"' > ssh.env")
+ else:
+ lines = len(value.split("\n"))
+ if lines > 1:
+ os.system(f"echo '{key}=\"' >> temp/env")
+ os.system(f"echo '{value}\"' >> temp/env")
+ else:
+ os.system(f"echo '{key}=\"{value}\"' >> temp/env")
+
+ for key, value in inputsAndSecrets.items():
+ if not key.startswith("_"):
+ continue
+ environment = (env if env else "").upper()
+ prefix = "_" + environment + "_"
+ if not key.startswith(prefix):
+ continue
+ else:
+ key = key.replace(prefix, "")
+ os.system(f"echo 'Secret found {key}...'")
+ if key == "SSH_KEY":
+ os.system(f"echo \"{value}\" > ssh.key")
+ elif key == "SSH_PASSWORD":
+ os.system(f"echo '{key}=\"{value}\"' > ssh.env")
+ else:
+ lines = len(value.split("\n"))
+ if lines > 1:
+ os.system(f"echo '{key}=\"' >> temp/env")
+ os.system(f"echo '{value}\"' >> temp/env")
+ else:
+ os.system(f"echo '{key}=\"{value}\"' >> temp/env")
+
+ # Execute deploy script
+ os.system(f"echo 'Executing deploy script for deployment: managerTag={managerTag} deploymentTag={deploymentRef} environment={env}'")
+ result = subprocess.run("bash .ci_cd/deploy.sh", shell=True)
+
+ if result.returncode != 0:
+ os.system(f"echo 'Deployment failed: managerTag={managerTag} deploymentTag={deploymentRef} environment={env}'")
+ failure = True
+ continue
+
+ if failure == True:
+ os.system("echo 'One or more deployments failed'")
+ sys.exit(1)
+ env:
+ REPO_NAME: ${{ github.repository }}
+ DEPLOYMENTS: ${{ steps.deployments.outputs.value }}
+ MANAGER_DOCKER_BUILD_PATH: ${{ steps.manager-docker-command.outputs.buildPath }}
+ DEPLOYMENT_DOCKER_BUILD_PATH: ${{ steps.deployment-docker-command.outputs.buildPath }}
+ MANAGER_REF: ${{ steps.manager-docker-command.outputs.refTag }}
+ DEPLOYMENT_REF: ${{ steps.deployment-docker-command.outputs.refTag }}
+ INPUTS_AND_SECRETS: ${{ toJSON(steps.inputs-and-secrets.outputs) }}
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index fc7afa2bc..000000000
--- a/Dockerfile
+++ /dev/null
@@ -1,83 +0,0 @@
-FROM debian:stretch-slim
-
-# Install utilities
-RUN apt-get update && apt-get install -y --no-install-recommends \
- apt-transport-https \
- gnupg2 \
- software-properties-common \
- procps \
- ca-certificates \
- curl \
- wget \
- && rm -rf /var/lib/apt/lists/*
-
-# Default to UTF-8 file.encoding
-ENV LANG C.UTF-8
-
-# add a simple script that can auto-detect the appropriate JAVA_HOME value
-# based on whether the JDK or only the JRE is installed
-RUN { \
- echo '#!/bin/sh'; \
- echo 'set -e'; \
- echo; \
- echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
- } > /usr/local/bin/docker-java-home \
- && chmod +x /usr/local/bin/docker-java-home
-
-# do some fancy footwork to create a JAVA_HOME that's cross-architecture-safe
-RUN ln -svT "/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)" /docker-java-home
-ENV JAVA_HOME /docker-java-home
-
-RUN set -ex; \
- \
-# deal with slim variants not having man page directories (which causes "update-alternatives" to fail)
- if [ ! -d /usr/share/man/man1 ]; then \
- mkdir -p /usr/share/man/man1; \
- fi; \
- \
- apt-get update; \
- apt-get install -y \
- openjdk-8-jdk \
- ca-certificates-java\
- ; \
- rm -rf /var/lib/apt/lists/*; \
- \
-# verify that "docker-java-home" returns what we expect
- [ "$(readlink -f "$JAVA_HOME")" = "$(docker-java-home)" ]; \
- \
-# update-alternatives so that future installs of other OpenJDK versions don't change /usr/bin/java
- update-alternatives --get-selections | awk -v home="$(readlink -f "$JAVA_HOME")" 'index($3, home) == 1 { $2 = "manual"; print | "update-alternatives --set-selections" }'; \
-# ... and verify that it actually worked for one of the alternatives we care about
- update-alternatives --query java | grep -q 'Status: manual'
-
-# Run postinst because it might not happen on install
-RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
-
-# Add git commit label must be specified at build time using --build-arg GIT_COMMIT=dadadadadad
-ARG GIT_COMMIT=unknown
-LABEL git-commit=$GIT_COMMIT
-
-############ EDITS ABOVE THIS LINE SHOULD BE DONE IN ALL DOCKERFILES! ################
-
-# Install Docker client
-RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
-RUN add-apt-repository \
- "deb [arch=amd64] https://download.docker.com/linux/debian \
- $(lsb_release -cs) \
- stable"
-RUN apt-get update && apt-get install -y --no-install-recommends \
- docker-ce docker-ce-cli containerd.io \
- && rm -rf /var/lib/apt/lists/*
-
-# Install Docker Compose executable
-RUN curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` \
- -o /usr/local/bin/docker-compose && \
- chmod +x /usr/local/bin/docker-compose
-
-# Install NodeJS 10 and Yarn and git
-RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
- apt-get install -y nodejs git && \
- npm install --global yarn
-
-WORKDIR /or
\ No newline at end of file
diff --git a/deployment/Dockerfile b/deployment/Dockerfile
new file mode 100644
index 000000000..bbfe332cf
--- /dev/null
+++ b/deployment/Dockerfile
@@ -0,0 +1,7 @@
+# ----------------------------------------------------------------------------------------
+# Docker image for populating deployment-data volume with project specific customisations
+# ----------------------------------------------------------------------------------------
+FROM alpine:latest
+
+RUN mkdir -p /deployment/manager/extensions
+ADD image /deployment
diff --git a/deployment/build.gradle b/deployment/build.gradle
new file mode 100644
index 000000000..94e615d91
--- /dev/null
+++ b/deployment/build.gradle
@@ -0,0 +1,10 @@
+task installDist(type: Copy) {
+ into("$buildDir")
+
+ from "Dockerfile"
+
+ into("image") {
+ from projectDir
+ exclude "build.gradle", "Dockerfile", "build", "**/*.mbtiles", "src", "**/*.md", ".gitignore"
+ }
+}
diff --git a/deployment/manager/app/manager_config.json b/deployment/manager/app/manager_config.json
new file mode 100644
index 000000000..486123d64
--- /dev/null
+++ b/deployment/manager/app/manager_config.json
@@ -0,0 +1,8 @@
+{
+ "realms": {
+ "default": {
+ "appTitle": "OpenRemote Manager Demo",
+ "language": "en"
+ }
+ }
+}
diff --git a/deployment/manager/provisioning/consoleappconfig/smartcity.json b/deployment/manager/provisioning/consoleappconfig/smartcity.json
new file mode 100644
index 000000000..41b45fa31
--- /dev/null
+++ b/deployment/manager/provisioning/consoleappconfig/smartcity.json
@@ -0,0 +1,16 @@
+{
+ "realm": "smartcity",
+ "initialUrl": "https://demo.openremote.io/console_loader/?realm=smartcity&consoleProviders=geofence push storage",
+ "url": "https://demo.openremote.io/manager/?realm=smartcity&consoleProviders=geofence push storage&consoleAutoEnable=true#!geofences",
+ "menuEnabled": false,
+ "menuPosition": "BOTTOM_RIGHT",
+ "menuImage": null,
+ "primaryColor": "#4D9D2A",
+ "secondaryColor": "#CFCFCF",
+ "links": [
+ {
+ "displayText": "Map",
+ "pageLink": "https://demo.openremote.io/console_loader/?realm=smartcity&consoleProviders=geofence push storage&consoleAutoEnable=true#!geofences"
+ }
+ ]
+}
diff --git a/deployment/map/mapsettings.json b/deployment/map/mapsettings.json
new file mode 100644
index 000000000..f0a9c1a99
--- /dev/null
+++ b/deployment/map/mapsettings.json
@@ -0,0 +1,4004 @@
+{
+ "options": {
+ "default": {
+ "center": [ 4.485222, 51.911712 ],
+ "bounds": [ 4.42, 51.88, 4.55, 51.94 ],
+ "zoom": 14,
+ "minZoom": 14,
+ "maxZoom": 19,
+ "boxZoom": false,
+ "geocodeUrl": "https://nominatim.openstreetmap.org"
+ },
+ "smartcity": {
+ "center": [ 4.485222, 51.911712 ],
+ "bounds": [ 4.42, 51.88, 4.55, 51.94 ],
+ "zoom": 15,
+ "minZoom": 14,
+ "maxZoom": 19,
+ "boxZoom": false,
+ "geocodeUrl": "https://nominatim.openstreetmap.org"
+ }
+ },
+ "version": 8,
+ "sources": {
+ "vector_tiles": {
+ "type": "vector",
+ "url": "mbtiles://mapdata.mbtiles"
+ }
+ },
+ "sprite": "map/sprites/bright-v9",
+ "glyphs": "{fontstack}/{range}.pbf",
+ "layers": [
+ {
+ "id": "background",
+ "type": "background",
+ "paint": {
+ "background-color": "#ecf2ea"
+ }
+ },
+ {
+ "id": "landcover-glacier",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landcover",
+ "filter": [
+ "==",
+ "subclass",
+ "glacier"
+ ],
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-color": "#fff",
+ "fill-opacity": {
+ "base": 1,
+ "stops": [
+ [ 0, 0.9 ],
+ [ 10, 0.3 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "landuse-residential",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landuse",
+ "filter": [
+ "==",
+ "class",
+ "residential"
+ ],
+ "paint": {
+ "fill-color": "#e1e6e0"
+ }
+ },
+ {
+ "id": "landuse-commercial",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landuse",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Polygon"
+ ],
+ [
+ "==",
+ "class",
+ "commercial"
+ ]
+ ],
+ "paint": {
+ "fill-color": "#e1e6e0"
+ }
+ },
+ {
+ "id": "landuse-industrial",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landuse",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Polygon"
+ ],
+ [
+ "==",
+ "class",
+ "industrial"
+ ]
+ ],
+ "paint": {
+ "fill-color": "#e1e6e0"
+ }
+ },
+ {
+ "id": "park",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "park",
+ "filter": [
+ "==",
+ "$type",
+ "Polygon"
+ ],
+ "paint": {
+ "fill-color": "#d8e8c8",
+ "fill-opacity": {
+ "base": 1.8,
+ "stops": [
+ [ 9, 0.5 ],
+ [ 12, 0.2 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "park-outline",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "park",
+ "filter": [
+ "==",
+ "$type",
+ "Polygon"
+ ],
+ "layout": {},
+ "paint": {
+ "line-color": {
+ "base": 1,
+ "stops": [
+ [ 6, "hsla(96, 40%, 49%, 0.36)" ],
+ [ 8, "hsla(96, 40%, 49%, 0.66)" ]
+ ]
+ },
+ "line-dasharray": [
+ 3,
+ 3
+ ]
+ }
+ },
+ {
+ "id": "landuse-cemetery",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landuse",
+ "filter": [
+ "==",
+ "class",
+ "cemetery"
+ ],
+ "paint": {
+ "fill-color": "#e1e6e0"
+ }
+ },
+ {
+ "id": "landuse-hospital",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landuse",
+ "filter": [
+ "==",
+ "class",
+ "hospital"
+ ],
+ "paint": {
+ "fill-color": "#e1e6e0"
+ }
+ },
+ {
+ "id": "landuse-school",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landuse",
+ "filter": [
+ "==",
+ "class",
+ "school"
+ ],
+ "paint": {
+ "fill-color": "#e1e6e0"
+ }
+ },
+ {
+ "id": "landuse-railway",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landuse",
+ "filter": [
+ "==",
+ "class",
+ "railway"
+ ],
+ "paint": {
+ "fill-color": "hsla(30, 19%, 90%, 0.4)"
+ }
+ },
+ {
+ "id": "landcover-wood",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landcover",
+ "filter": [
+ "==",
+ "class",
+ "wood"
+ ],
+ "paint": {
+ "fill-color": "#6a4",
+ "fill-opacity": 0.1,
+ "fill-outline-color": "hsla(0, 0%, 0%, 0.03)",
+ "fill-antialias": {
+ "base": 1,
+ "stops": [
+ [ 0, false ],
+ [ 9, true ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "landcover-grass",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landcover",
+ "filter": [
+ "==",
+ "class",
+ "grass"
+ ],
+ "paint": {
+ "fill-color": "#d8e8c8",
+ "fill-opacity": 1
+ }
+ },
+ {
+ "id": "landcover-grass-park",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849388993.3071"
+ },
+ "source": "vector_tiles",
+ "source-layer": "park",
+ "filter": [
+ "==",
+ "class",
+ "public_park"
+ ],
+ "paint": {
+ "fill-color": "#d8e8c8",
+ "fill-opacity": 0.8
+ }
+ },
+ {
+ "id": "waterway-other",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849382550.77"
+ },
+ "source": "vector_tiles",
+ "source-layer": "waterway",
+ "filter": [
+ "!in",
+ "class",
+ "canal",
+ "river",
+ "stream"
+ ],
+ "layout": {
+ "line-cap": "round"
+ },
+ "paint": {
+ "line-color": "#bad4ff",
+ "line-width": {
+ "base": 1.3,
+ "stops": [
+ [ 13, 0.5 ],
+ [ 20, 2 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "waterway-stream-canal",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849382550.77"
+ },
+ "source": "vector_tiles",
+ "source-layer": "waterway",
+ "filter": [
+ "in",
+ "class",
+ "canal",
+ "stream"
+ ],
+ "layout": {
+ "line-cap": "round"
+ },
+ "paint": {
+ "line-color": "#bad4ff",
+ "line-width": {
+ "base": 1.3,
+ "stops": [
+ [ 13, 0.5 ],
+ [ 20, 6 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "waterway-river",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849382550.77"
+ },
+ "source": "vector_tiles",
+ "source-layer": "waterway",
+ "filter": [
+ "==",
+ "class",
+ "river"
+ ],
+ "layout": {
+ "line-cap": "round"
+ },
+ "paint": {
+ "line-color": "#bad4ff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [ 10, 0.8 ],
+ [ 20, 6 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "water-offset",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849382550.77"
+ },
+ "source": "vector_tiles",
+ "source-layer": "water",
+ "maxzoom": 8,
+ "filter": [
+ "==",
+ "$type",
+ "Polygon"
+ ],
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-opacity": 1,
+ "fill-color": "#bad4ff",
+ "fill-translate": {
+ "base": 1,
+ "stops": [
+ [
+ 6,
+ [ 2, 0 ]
+ ],
+ [
+ 8,
+ [ 0, 0 ]
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "water",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849382550.77"
+ },
+ "source": "vector_tiles",
+ "source-layer": "water",
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-color": "#bad4ff"
+ }
+ },
+ {
+ "id": "water-pattern",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849382550.77"
+ },
+ "source": "vector_tiles",
+ "source-layer": "water",
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-translate": [
+ 0,
+ 2.5
+ ],
+ "fill-pattern": "wave"
+ }
+ },
+ {
+ "id": "landcover-ice-shelf",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849382550.77"
+ },
+ "source": "vector_tiles",
+ "source-layer": "landcover",
+ "filter": [
+ "==",
+ "subclass",
+ "ice_shelf"
+ ],
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-color": "#fff",
+ "fill-opacity": {
+ "base": 1,
+ "stops": [
+ [ 0, 0.9 ],
+ [ 10, 0.3 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "building",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849364238.8171"
+ },
+ "source": "vector_tiles",
+ "source-layer": "building",
+ "paint": {
+ "fill-color": {
+ "base": 1,
+ "stops": [
+ [ 15.5, "#cbd8c5" ],
+ [ 16, "#cbd8c5" ]
+ ]
+ },
+ "fill-antialias": true
+ }
+ },
+ {
+ "id": "building-top",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849364238.8171"
+ },
+ "source": "vector_tiles",
+ "source-layer": "building",
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-translate": {
+ "base": 1,
+ "stops": [
+ [
+ 14,
+ [ 0, 0 ]
+ ],
+ [
+ 16,
+ [ -2, -2 ]
+ ]
+ ]
+ },
+ "fill-outline-color": "#aaa",
+ "fill-color": "#cbd8c5",
+ "fill-opacity": {
+ "base": 1,
+ "stops": [
+ [ 13, 0 ],
+ [ 16, 1 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "housenumber",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "housenumber",
+ "minzoom": 18,
+ "filter": [
+ "==",
+ "$type",
+ "Point"
+ ],
+ "layout": {
+ "text-field": "{housenumber}",
+ "text-size": 10,
+ "text-font": [
+ "Open Sans Italic"
+ ]
+ },
+ "paint": {
+ "text-color": "#666"
+ }
+ },
+ {
+ "id": "tunnel-service-track-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "service",
+ "track"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#aaa",
+ "line-dasharray": [
+ 0.5,
+ 0.25
+ ],
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [ 15, 1 ],
+ [ 16, 4 ],
+ [ 20, 11 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-minor-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "minor"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#aaa",
+ "line-opacity": {
+ "stops": [
+ [
+ 12,
+ 0
+ ],
+ [
+ 12.5,
+ 1
+ ]
+ ]
+ },
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12,
+ 0.5
+ ],
+ [
+ 13,
+ 1
+ ],
+ [
+ 14,
+ 4
+ ],
+ [
+ 20,
+ 15
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-secondary-tertiary-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "secondary",
+ "tertiary"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#aaa",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 8,
+ 1.5
+ ],
+ [
+ 20,
+ 17
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-trunk-primary-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "primary",
+ "trunk"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#aaa",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 5,
+ 0.4
+ ],
+ [
+ 6,
+ 0.6
+ ],
+ [
+ 7,
+ 1.5
+ ],
+ [
+ 20,
+ 22
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-motorway-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "motorway"
+ ]
+ ],
+ "layout": {
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#aaa",
+ "line-dasharray": [
+ 0.5,
+ 0.25
+ ],
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 5,
+ 0.4
+ ],
+ [
+ 6,
+ 0.6
+ ],
+ [
+ 7,
+ 1.5
+ ],
+ [
+ 20,
+ 22
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-path",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "path"
+ ]
+ ]
+ ],
+ "paint": {
+ "line-color": "#555",
+ "line-dasharray": [
+ 1.5,
+ 0.75
+ ],
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 15,
+ 1.2
+ ],
+ [
+ 20,
+ 4
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-service-track",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "service",
+ "track"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#fff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 15.5,
+ 0
+ ],
+ [
+ 16,
+ 2
+ ],
+ [
+ 20,
+ 7.5
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-minor",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "minor_road"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#fff",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 13.5,
+ 0
+ ],
+ [
+ 14,
+ 2.5
+ ],
+ [
+ 20,
+ 11.5
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-secondary-tertiary",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "secondary",
+ "tertiary"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#444",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 10
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-trunk-primary",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "primary",
+ "trunk"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#fff4c6",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 18
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-motorway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "motorway"
+ ]
+ ],
+ "layout": {
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#aaa",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 18
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "tunnel-railway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849354174.1904"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "rail"
+ ]
+ ],
+ "paint": {
+ "line-color": "#bbb",
+ "line-width": {
+ "base": 1.4,
+ "stops": [
+ [ 14, 0.4 ],
+ [ 15, 0.75 ],
+ [ 20, 2 ]
+ ]
+ },
+ "line-dasharray": [
+ 2,
+ 2
+ ]
+ }
+ },
+ {
+ "id": "aeroway-taxiway-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "aeroway",
+ "minzoom": 12,
+ "filter": [
+ "all",
+ [
+ "in",
+ "class",
+ "taxiway"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "rgba(153, 153, 153, 1)",
+ "line-width": {
+ "base": 1.5,
+ "stops": [
+ [
+ 11,
+ 2
+ ],
+ [
+ 17,
+ 12
+ ]
+ ]
+ },
+ "line-opacity": 1
+ }
+ },
+ {
+ "id": "aeroway-runway-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "aeroway",
+ "minzoom": 12,
+ "filter": [
+ "all",
+ [
+ "in",
+ "class",
+ "runway"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#aaa",
+ "line-width": {
+ "base": 1.5,
+ "stops": [
+ [
+ 11,
+ 5
+ ],
+ [
+ 17,
+ 55
+ ]
+ ]
+ },
+ "line-opacity": 1
+ }
+ },
+ {
+ "id": "aeroway-area",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "aeroway",
+ "minzoom": 4,
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Polygon"
+ ],
+ [
+ "in",
+ "class",
+ "runway",
+ "taxiway"
+ ]
+ ],
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-opacity": {
+ "base": 1,
+ "stops": [
+ [ 13, 0 ],
+ [ 14, 1 ]
+ ]
+ },
+ "fill-color": "#f0f0f0"
+ }
+ },
+ {
+ "id": "aeroway-taxiway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "aeroway",
+ "minzoom": 4,
+ "filter": [
+ "all",
+ [
+ "in",
+ "class",
+ "taxiway"
+ ],
+ [
+ "==",
+ "$type",
+ "LineString"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#e9e9e9",
+ "line-width": {
+ "base": 1.5,
+ "stops": [
+ [ 11, 1 ],
+ [ 17, 10 ]
+ ]
+ },
+ "line-opacity": {
+ "base": 1,
+ "stops": [
+ [ 11, 0 ],
+ [ 12, 1 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "aeroway-runway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "aeroway",
+ "minzoom": 4,
+ "filter": [
+ "all",
+ [
+ "in",
+ "class",
+ "runway"
+ ],
+ [
+ "==",
+ "$type",
+ "LineString"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#f0f0f0",
+ "line-width": {
+ "base": 1.5,
+ "stops": [
+ [ 11, 4 ],
+ [ 17, 50 ]
+ ]
+ },
+ "line-opacity": {
+ "base": 1,
+ "stops": [
+ [ 11, 0 ],
+ [ 12, 1 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-area",
+ "type": "fill",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "==",
+ "$type",
+ "Polygon"
+ ],
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "fill-color": "hsla(0, 0%, 89%, 0.56)",
+ "fill-outline-color": "#cfcdca",
+ "fill-opacity": 0.9,
+ "fill-antialias": false
+ }
+ },
+ {
+ "id": "highway-motorway-link-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "minzoom": 12,
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "motorway_link"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12,
+ 1
+ ],
+ [
+ 13,
+ 3
+ ],
+ [
+ 14,
+ 4
+ ],
+ [
+ 20,
+ 15
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-link-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "minzoom": 13,
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#e9ac77",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12,
+ 1
+ ],
+ [
+ 13,
+ 3
+ ],
+ [
+ 14,
+ 4
+ ],
+ [
+ 20,
+ 15
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-minor-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "!=",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "minor",
+ "service",
+ "track"
+ ]
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#cfcdca",
+ "line-opacity": {
+ "stops": [
+ [
+ 12,
+ 0
+ ],
+ [
+ 12.5,
+ 1
+ ]
+ ]
+ },
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12,
+ 0.5
+ ],
+ [
+ 13,
+ 1
+ ],
+ [
+ 14,
+ 4
+ ],
+ [
+ 20,
+ 15
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-secondary-tertiary-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "secondary",
+ "tertiary"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#999999",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 8,
+ 1.5
+ ],
+ [
+ 20,
+ 17
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-trunk-primary-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "minzoom": 5,
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "primary",
+ "trunk"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#a0a0a0",
+ "line-opacity": {
+ "stops": [
+ [
+ 5,
+ 0
+ ],
+ [
+ 6,
+ 1
+ ]
+ ]
+ },
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 5,
+ 0
+ ],
+ [
+ 6,
+ 0.6
+ ],
+ [
+ 7,
+ 1.5
+ ],
+ [
+ 20,
+ 22
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-motorway-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "minzoom": 4,
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "motorway"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#a0a0a0",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 4,
+ 0
+ ],
+ [
+ 5,
+ 0.4
+ ],
+ [
+ 6,
+ 0.6
+ ],
+ [
+ 7,
+ 1.5
+ ],
+ [
+ 20,
+ 22
+ ]
+ ]
+ },
+ "line-opacity": {
+ "stops": [
+ [
+ 4,
+ 0
+ ],
+ [
+ 5,
+ 1
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-path",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "path"
+ ]
+ ]
+ ],
+ "paint": {
+ "line-color": "#d0d0d0",
+ "line-dasharray": [
+ 1.5,
+ 0.75
+ ],
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 15,
+ 1.2
+ ],
+ [
+ 20,
+ 4
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-motorway-link",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "minzoom": 12,
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "motorway_link"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12.5,
+ 0
+ ],
+ [
+ 13,
+ 1.5
+ ],
+ [
+ 14,
+ 2.5
+ ],
+ [
+ 20,
+ 11.5
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-link",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "minzoom": 13,
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12.5,
+ 0
+ ],
+ [
+ 13,
+ 1.5
+ ],
+ [
+ 14,
+ 2.5
+ ],
+ [
+ 20,
+ 11.5
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-minor",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "!=",
+ "brunnel",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "minor",
+ "service",
+ "track"
+ ]
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 13.5,
+ 0
+ ],
+ [
+ 14,
+ 2.5
+ ],
+ [
+ 20,
+ 11.5
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-secondary-tertiary",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "secondary",
+ "tertiary"
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 8,
+ 0.5
+ ],
+ [
+ 20,
+ 13
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-trunk-primary",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "in",
+ "class",
+ "primary",
+ "trunk"
+ ]
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 18
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "highway-motorway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "minzoom": 5,
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "motorway"
+ ]
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round",
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 18
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "railway-service",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "==",
+ "class",
+ "rail"
+ ],
+ [
+ "has",
+ "service"
+ ]
+ ]
+ ],
+ "paint": {
+ "line-color": "hsla(0, 0%, 73%, 0.77)",
+ "line-width": {
+ "base": 1.4,
+ "stops": [
+ [
+ 14,
+ 0.4
+ ],
+ [
+ 20,
+ 1
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "railway-service-hatching",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "==",
+ "class",
+ "rail"
+ ],
+ [
+ "has",
+ "service"
+ ]
+ ]
+ ],
+ "layout": {
+ "visibility": "visible"
+ },
+ "paint": {
+ "line-color": "hsla(0, 0%, 73%, 0.68)",
+ "line-dasharray": [
+ 0.2,
+ 8
+ ],
+ "line-width": {
+ "base": 1.4,
+ "stops": [
+ [
+ 14.5,
+ 0
+ ],
+ [
+ 15,
+ 2
+ ],
+ [
+ 20,
+ 6
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "railway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "!has",
+ "service"
+ ],
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "rail"
+ ]
+ ]
+ ],
+ "paint": {
+ "line-color": "#bbb",
+ "line-width": {
+ "base": 1.4,
+ "stops": [
+ [
+ 14,
+ 0.4
+ ],
+ [
+ 15,
+ 0.75
+ ],
+ [
+ 20,
+ 2
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "railway-hatching",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849345966.4436"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "!has",
+ "service"
+ ],
+ [
+ "!in",
+ "brunnel",
+ "bridge",
+ "tunnel"
+ ],
+ [
+ "==",
+ "class",
+ "rail"
+ ]
+ ]
+ ],
+ "paint": {
+ "line-color": "#bbb",
+ "line-dasharray": [
+ 0.2,
+ 8
+ ],
+ "line-width": {
+ "base": 1.4,
+ "stops": [
+ [
+ 14.5,
+ 0
+ ],
+ [
+ 15,
+ 3
+ ],
+ [
+ 20,
+ 8
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-motorway-link-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "motorway_link"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#777",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12,
+ 1
+ ],
+ [
+ 13,
+ 3
+ ],
+ [
+ 14,
+ 4
+ ],
+ [
+ 20,
+ 15
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-link-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#666",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12,
+ 1
+ ],
+ [
+ 13,
+ 3
+ ],
+ [
+ 14,
+ 4
+ ],
+ [
+ 20,
+ 15
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-secondary-tertiary-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "in",
+ "class",
+ "secondary",
+ "tertiary"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#777",
+ "line-opacity": 1,
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 8,
+ 1.5
+ ],
+ [
+ 20,
+ 28
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-trunk-primary-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "in",
+ "class",
+ "primary",
+ "trunk"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#777",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 5,
+ 0.4
+ ],
+ [
+ 6,
+ 0.6
+ ],
+ [
+ 7,
+ 1.5
+ ],
+ [
+ 20,
+ 26
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-motorway-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "motorway"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#777",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 5,
+ 0.4
+ ],
+ [
+ 6,
+ 0.6
+ ],
+ [
+ 7,
+ 1.5
+ ],
+ [
+ 20,
+ 22
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-path-casing",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "path"
+ ]
+ ]
+ ],
+ "paint": {
+ "line-color": "#777",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 15,
+ 1.2
+ ],
+ [
+ 20,
+ 18
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-path",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "path"
+ ]
+ ]
+ ],
+ "paint": {
+ "line-color": "#ddd",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 15,
+ 1.2
+ ],
+ [
+ 20,
+ 4
+ ]
+ ]
+ },
+ "line-dasharray": [
+ 1.5,
+ 0.75
+ ]
+ }
+ },
+ {
+ "id": "bridge-motorway-link",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "motorway_link"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12.5,
+ 0
+ ],
+ [
+ 13,
+ 1.5
+ ],
+ [
+ 14,
+ 2.5
+ ],
+ [
+ 20,
+ 11.5
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-link",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "in",
+ "class",
+ "primary_link",
+ "secondary_link",
+ "tertiary_link",
+ "trunk_link"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#ffffff",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12.5,
+ 0
+ ],
+ [
+ 13,
+ 1.5
+ ],
+ [
+ 14,
+ 2.5
+ ],
+ [
+ 20,
+ 11.5
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-secondary-tertiary",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "in",
+ "class",
+ "secondary",
+ "tertiary"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#f5f5f5",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 20
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-trunk-primary",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "in",
+ "class",
+ "primary",
+ "trunk"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#f0f0f0",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 18
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-motorway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "motorway"
+ ]
+ ],
+ "layout": {
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#f0f0f0",
+ "line-width": {
+ "base": 1.2,
+ "stops": [
+ [
+ 6.5,
+ 0
+ ],
+ [
+ 7,
+ 0.5
+ ],
+ [
+ 20,
+ 18
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-railway",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "rail"
+ ]
+ ],
+ "paint": {
+ "line-color": "#f0f0f0",
+ "line-width": {
+ "base": 1.4,
+ "stops": [
+ [
+ 14,
+ 0.4
+ ],
+ [
+ 15,
+ 0.75
+ ],
+ [
+ 20,
+ 2
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "bridge-railway-hatching",
+ "type": "line",
+ "metadata": {
+ "mapbox:group": "1444849334699.1902"
+ },
+ "source": "vector_tiles",
+ "source-layer": "transportation",
+ "filter": [
+ "all",
+ [
+ "==",
+ "brunnel",
+ "bridge"
+ ],
+ [
+ "==",
+ "class",
+ "rail"
+ ]
+ ],
+ "paint": {
+ "line-color": "#bbb",
+ "line-dasharray": [
+ 0.2,
+ 8
+ ],
+ "line-width": {
+ "base": 1.4,
+ "stops": [
+ [
+ 14.5,
+ 0
+ ],
+ [
+ 15,
+ 3
+ ],
+ [
+ 20,
+ 8
+ ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "boundary-water",
+ "type": "line",
+ "source": "vector_tiles",
+ "source-layer": "boundary",
+ "filter": [
+ "all",
+ [
+ "in",
+ "admin_level",
+ 2,
+ 4
+ ],
+ [
+ "==",
+ "maritime",
+ 1
+ ]
+ ],
+ "layout": {
+ "line-cap": "round",
+ "line-join": "round"
+ },
+ "paint": {
+ "line-color": "#8ca0c2",
+ "line-width": {
+ "base": 1,
+ "stops": [
+ [ 0, 0.6 ],
+ [ 4, 1.4 ],
+ [ 5, 2 ],
+ [ 12, 8 ]
+ ]
+ },
+ "line-opacity": {
+ "stops": [
+ [ 6, 0.6 ],
+ [ 10, 1 ]
+ ]
+ }
+ }
+ },
+ {
+ "id": "waterway-name",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "waterway",
+ "minzoom": 13,
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "has",
+ "name"
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Italic"
+ ],
+ "text-size": 14,
+ "text-field": "{name}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "line",
+ "text-letter-spacing": 0.2,
+ "symbol-spacing": 350
+ },
+ "paint": {
+ "text-color": "#687692",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "water-name-lakeline",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "water_name",
+ "filter": [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Italic"
+ ],
+ "text-size": 14,
+ "text-field": "{name}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "line",
+ "symbol-spacing": 350,
+ "text-letter-spacing": 0.2
+ },
+ "paint": {
+ "text-color": "#687692",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "water-name-ocean",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "water_name",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Point"
+ ],
+ [
+ "==",
+ "class",
+ "ocean"
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Italic"
+ ],
+ "text-size": 14,
+ "text-field": "{name}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "point",
+ "symbol-spacing": 350,
+ "text-letter-spacing": 0.2
+ },
+ "paint": {
+ "text-color": "#687692",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "water-name-other",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "water_name",
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Point"
+ ],
+ [
+ "!in",
+ "class",
+ "ocean"
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Italic"
+ ],
+ "text-size": {
+ "stops": [
+ [ 0, 10 ],
+ [ 6, 14 ]
+ ]
+ },
+ "text-field": "{name}",
+ "text-max-width": 5,
+ "text-rotation-alignment": "map",
+ "symbol-placement": "point",
+ "symbol-spacing": 350,
+ "text-letter-spacing": 0.2,
+ "visibility": "visible"
+ },
+ "paint": {
+ "text-color": "#687692",
+ "text-halo-width": 1.5,
+ "text-halo-color": "rgba(255,255,255,0.7)"
+ }
+ },
+ {
+ "id": "poi-level-3",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "poi",
+ "minzoom": 16,
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Point"
+ ],
+ [
+ ">=",
+ "rank",
+ 25
+ ]
+ ],
+ "layout": {
+ "text-padding": 2,
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "text-anchor": "top",
+ "icon-image": "{class}_11",
+ "text-field": "{name}",
+ "text-offset": [
+ 0,
+ 0.6
+ ],
+ "text-size": 12,
+ "text-max-width": 9
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#999",
+ "text-halo-width": 1,
+ "text-halo-color": "#ffffff"
+ }
+ },
+ {
+ "id": "poi-level-2",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "poi",
+ "minzoom": 15,
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Point"
+ ],
+ [
+ "all",
+ [
+ "<=",
+ "rank",
+ 24
+ ],
+ [
+ ">=",
+ "rank",
+ 15
+ ]
+ ]
+ ],
+ "layout": {
+ "text-padding": 2,
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "text-anchor": "top",
+ "icon-image": "{class}_11",
+ "text-field": "{name}",
+ "text-offset": [
+ 0,
+ 0.6
+ ],
+ "text-size": 12,
+ "text-max-width": 9
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#999",
+ "text-halo-width": 1,
+ "text-halo-color": "#ffffff"
+ }
+ },
+ {
+ "id": "poi-level-1",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "poi",
+ "minzoom": 14,
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "Point"
+ ],
+ [
+ "all",
+ [
+ "<=",
+ "rank",
+ 14
+ ],
+ [
+ "has",
+ "name"
+ ]
+ ]
+ ],
+ "layout": {
+ "text-padding": 2,
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "text-anchor": "top",
+ "icon-image": "{class}_11",
+ "text-field": "{name}",
+ "text-offset": [
+ 0,
+ 0.6
+ ],
+ "text-size": 12,
+ "text-max-width": 9
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#999",
+ "text-halo-width": 1,
+ "text-halo-color": "#ffffff"
+ }
+ },
+ {
+ "id": "highway-name-path",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "transportation_name",
+ "minzoom": 15.5,
+ "filter": [
+ "==",
+ "class",
+ "path"
+ ],
+ "layout": {
+ "text-size": {
+ "base": 1,
+ "stops": [
+ [
+ 13,
+ 12
+ ],
+ [
+ 14,
+ 13
+ ]
+ ]
+ },
+ "text-font": [
+ "Open Sans Regular"
+ ],
+ "text-field": "{name}",
+ "symbol-placement": "line",
+ "text-rotation-alignment": "map"
+ },
+ "paint": {
+ "text-halo-color": "#f8f4f0",
+ "text-color": "#444",
+ "text-halo-width": 0.5
+ }
+ },
+ {
+ "id": "highway-name-minor",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "transportation_name",
+ "minzoom": 15,
+ "filter": [
+ "all",
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "in",
+ "class",
+ "minor",
+ "service",
+ "track"
+ ]
+ ],
+ "layout": {
+ "text-size": {
+ "base": 1,
+ "stops": [
+ [
+ 13,
+ 12
+ ],
+ [
+ 14,
+ 13
+ ]
+ ]
+ },
+ "text-font": [
+ "Open Sans Regular"
+ ],
+ "text-field": "{name}",
+ "symbol-placement": "line",
+ "text-rotation-alignment": "map"
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#666",
+ "text-halo-width": 1
+ }
+ },
+ {
+ "id": "highway-name-major",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "transportation_name",
+ "minzoom": 12.2,
+ "filter": [
+ "in",
+ "class",
+ "primary",
+ "secondary",
+ "tertiary",
+ "trunk"
+ ],
+ "layout": {
+ "text-size": {
+ "base": 1,
+ "stops": [
+ [
+ 13,
+ 12
+ ],
+ [
+ 14,
+ 13
+ ]
+ ]
+ },
+ "text-font": [
+ "Open Sans Regular"
+ ],
+ "text-field": "{name}",
+ "symbol-placement": "line",
+ "text-rotation-alignment": "map"
+ },
+ "paint": {
+ "text-halo-blur": 0.5,
+ "text-color": "#666",
+ "text-halo-width": 1
+ }
+ },
+ {
+ "id": "highway-shield",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "transportation_name",
+ "minzoom": 8,
+ "filter": [
+ "all",
+ [
+ "<=",
+ "ref_length",
+ 6
+ ],
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "!in",
+ "network",
+ "us-interstate",
+ "us-highway",
+ "us-state"
+ ]
+ ],
+ "layout": {
+ "text-size": 12,
+ "icon-image": "road_{ref_length}",
+ "icon-rotation-alignment": "viewport",
+ "symbol-spacing": 200,
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "symbol-placement": {
+ "base": 1,
+ "stops": [
+ [
+ 10,
+ "point"
+ ],
+ [
+ 11,
+ "line"
+ ]
+ ]
+ },
+ "text-rotation-alignment": "viewport",
+ "icon-size": 1,
+ "text-field": "{ref}"
+ },
+ "paint": {
+ "text-color": "#666"
+ }
+ },
+ {
+ "id": "highway-shield-us-interstate",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "transportation_name",
+ "minzoom": 7,
+ "filter": [
+ "all",
+ [
+ "<=",
+ "ref_length",
+ 6
+ ],
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "in",
+ "network",
+ "us-interstate"
+ ]
+ ],
+ "layout": {
+ "text-size": 10,
+ "icon-image": "{network}_{ref_length}",
+ "icon-rotation-alignment": "viewport",
+ "symbol-spacing": 200,
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "symbol-placement": {
+ "base": 1,
+ "stops": [
+ [
+ 7,
+ "point"
+ ],
+ [
+ 7,
+ "line"
+ ],
+ [
+ 8,
+ "line"
+ ]
+ ]
+ },
+ "text-rotation-alignment": "viewport",
+ "icon-size": 1,
+ "text-field": "{ref}"
+ },
+ "paint": {
+ "text-color": "rgba(0, 0, 0, 1)"
+ }
+ },
+ {
+ "id": "highway-shield-us-other",
+ "type": "symbol",
+ "source": "vector_tiles",
+ "source-layer": "transportation_name",
+ "minzoom": 9,
+ "filter": [
+ "all",
+ [
+ "<=",
+ "ref_length",
+ 6
+ ],
+ [
+ "==",
+ "$type",
+ "LineString"
+ ],
+ [
+ "in",
+ "network",
+ "us-highway",
+ "us-state"
+ ]
+ ],
+ "layout": {
+ "text-size": 10,
+ "icon-image": "{network}_{ref_length}",
+ "icon-rotation-alignment": "viewport",
+ "symbol-spacing": 200,
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "symbol-placement": {
+ "base": 1,
+ "stops": [
+ [
+ 10,
+ "point"
+ ],
+ [
+ 11,
+ "line"
+ ]
+ ]
+ },
+ "text-rotation-alignment": "viewport",
+ "icon-size": 1,
+ "text-field": "{ref}"
+ },
+ "paint": {
+ "text-color": "rgba(0, 0, 0, 1)"
+ }
+ },
+ {
+ "id": "place-other",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "!in",
+ "class",
+ "city",
+ "town",
+ "village"
+ ],
+ "layout": {
+ "text-letter-spacing": 0.1,
+ "text-size": {
+ "base": 1.2,
+ "stops": [
+ [
+ 12,
+ 10
+ ],
+ [
+ 15,
+ 14
+ ]
+ ]
+ },
+ "text-font": [
+ "Open Sans Bold"
+ ],
+ "text-field": "{name_en}",
+ "text-transform": "uppercase",
+ "text-max-width": 9
+ },
+ "paint": {
+ "text-color": "#888",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-village",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "==",
+ "class",
+ "village"
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Regular"
+ ],
+ "text-size": {
+ "base": 1.2,
+ "stops": [
+ [
+ 10,
+ 12
+ ],
+ [
+ 15,
+ 22
+ ]
+ ]
+ },
+ "text-field": "{name_en}",
+ "text-max-width": 8
+ },
+ "paint": {
+ "text-color": "#444",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-town",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "==",
+ "class",
+ "town"
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Regular"
+ ],
+ "text-size": {
+ "base": 1.2,
+ "stops": [
+ [
+ 10,
+ 14
+ ],
+ [
+ 15,
+ 24
+ ]
+ ]
+ },
+ "text-field": "{name_en}",
+ "text-max-width": 8
+ },
+ "paint": {
+ "text-color": "#444",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-city",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ [
+ "!=",
+ "capital",
+ 2
+ ],
+ [
+ "==",
+ "class",
+ "city"
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "text-size": {
+ "base": 1.2,
+ "stops": [
+ [
+ 7,
+ 14
+ ],
+ [
+ 11,
+ 24
+ ]
+ ]
+ },
+ "text-field": "{name_en}",
+ "text-max-width": 8
+ },
+ "paint": {
+ "text-color": "#666",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-city-capital",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ [
+ "==",
+ "capital",
+ 2
+ ],
+ [
+ "==",
+ "class",
+ "city"
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Semibold"
+ ],
+ "text-size": {
+ "base": 1.2,
+ "stops": [
+ [
+ 7,
+ 14
+ ],
+ [
+ 11,
+ 24
+ ]
+ ]
+ },
+ "text-field": "{name_en}",
+ "text-max-width": 8,
+ "icon-image": "star_11",
+ "text-offset": [
+ 0.4,
+ 0
+ ],
+ "icon-size": 0.8,
+ "text-anchor": "left"
+ },
+ "paint": {
+ "text-color": "#444",
+ "text-halo-width": 1.2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-country-3",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ [
+ "==",
+ "class",
+ "country"
+ ],
+ [
+ ">=",
+ "rank",
+ 3
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Bold"
+ ],
+ "text-field": "{name_en}",
+ "text-size": {
+ "stops": [
+ [
+ 3,
+ 11
+ ],
+ [
+ 7,
+ 17
+ ]
+ ]
+ },
+ "text-transform": "uppercase",
+ "text-max-width": 6.25
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#444",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-country-2",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ [
+ "==",
+ "class",
+ "country"
+ ],
+ [
+ "==",
+ "rank",
+ 2
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Bold"
+ ],
+ "text-field": "{name_en}",
+ "text-size": {
+ "stops": [
+ [
+ 2,
+ 11
+ ],
+ [
+ 5,
+ 17
+ ]
+ ]
+ },
+ "text-transform": "uppercase",
+ "text-max-width": 6.25
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#444",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-country-1",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "filter": [
+ "all",
+ [
+ "==",
+ "class",
+ "country"
+ ],
+ [
+ "==",
+ "rank",
+ 1
+ ]
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Bold"
+ ],
+ "text-field": "{name_en}",
+ "text-size": {
+ "stops": [
+ [
+ 1,
+ 11
+ ],
+ [
+ 4,
+ 17
+ ]
+ ]
+ },
+ "text-transform": "uppercase",
+ "text-max-width": 6.25
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#444",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ },
+ {
+ "id": "place-continent",
+ "type": "symbol",
+ "metadata": {
+ "mapbox:group": "1444849242106.713"
+ },
+ "source": "vector_tiles",
+ "source-layer": "place",
+ "maxzoom": 1,
+ "filter": [
+ "==",
+ "class",
+ "continent"
+ ],
+ "layout": {
+ "text-font": [
+ "Open Sans Bold"
+ ],
+ "text-field": "{name_en}",
+ "text-size": 14,
+ "text-max-width": 6.25,
+ "text-transform": "uppercase"
+ },
+ "paint": {
+ "text-halo-blur": 1,
+ "text-color": "#444",
+ "text-halo-width": 2,
+ "text-halo-color": "rgba(255,255,255,0.8)"
+ }
+ }
+ ]
+}