Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/publish-maven-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-

- name: Installing Groovy 3 version
- name: Compile and install locally
run: |


mkdir -p repository/com/eficode/devstack
echo Compiling, Packaging and Installing Groovy 3.0 version of library to local m2 directory
mvn install -P groovy-3 -DcreateChecksum=true -Drevision=3.0



- name: Installing Groovy 2.5 Version
run: |
mvn help:effective-pom -P groovy-3,groovy-3.0.14 -Doutput=effective-pom.xml
mvn install -f effective-pom.xml -DcreateChecksum=true

mvn help:effective-pom -P groovy-3,groovy-3.0.13 -Doutput=effective-pom.xml
mvn install -f effective-pom.xml -DcreateChecksum=true

echo Compiling, Packaging and Installing Groovy 2.5 version of library to local m2 directory
mvn install -P groovy-2.5 -DcreateChecksum=true -Drevision=2.5
mvn help:effective-pom -P groovy-3,groovy-3.0.12 -Doutput=effective-pom.xml
mvn install -f effective-pom.xml -DcreateChecksum=true

mvn help:effective-pom -P groovy-3,groovy-3.0.11 -Doutput=effective-pom.xml
mvn install -f effective-pom.xml -DcreateChecksum=true

- name: Copying JAR files
run: |
Expand All @@ -78,7 +78,7 @@ jobs:
echo Adding repository files to git
git add repository/*
echo Committing changes
git commit -m "Updated packages to $VERSION"
git commit -m "Updated packages"
echo Pushing changes
git push

25 changes: 18 additions & 7 deletions Environments/AWS/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ data "aws_availability_zones" "available" {
}


data "aws_ec2_instance_type" "instance_type" {

instance_type = var.ec2-instance-type
}



//Get the latest AmazoneLinux2 AMI
data "aws_ami" "latest_amazon_linux_2" {
most_recent = true
Expand All @@ -73,7 +80,7 @@ data "aws_ami" "latest_amazon_linux_2" {
}
filter {
name = "architecture"
values = ["x86_64"]
values = data.aws_ec2_instance_type.instance_type.supported_architectures
}
owners = ["amazon"]
}
Expand All @@ -84,14 +91,18 @@ data "aws_ami" "ubuntuAMI" {

filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-*-server-*"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

filter {
name = "architecture"
values = data.aws_ec2_instance_type.instance_type.supported_architectures
}
owners = ["099720109477"] # Canonical
}

Expand Down Expand Up @@ -259,7 +270,7 @@ resource "aws_instance" "ec2-node" {
}

ami = data.aws_ami.ubuntuAMI.id
instance_type = "t3.xlarge"
instance_type = var.ec2-instance-type
subnet_id = aws_subnet.base-stack-private-subnet.id
key_name = aws_key_pair.ec2-ssh-key.key_name
vpc_security_group_ids = [aws_security_group.private-subnet-sg.id]
Expand All @@ -273,9 +284,9 @@ resource "aws_instance" "ec2-node" {

user_data = templatefile("ubuntu_user_data.sh", {
awsRegion : data.aws_region.current.name
tlscacert : file(var.dockerServerCert.tlscacert)
tlscert : file(var.dockerServerCert.tlscert)
tlskey : file(var.dockerServerCert.tlskey)
tlscacert : file(pathexpand(var.dockerServerCert.tlscacert))
tlscert : file(pathexpand(var.dockerServerCert.tlscert))
tlskey : file(pathexpand(var.dockerServerCert.tlskey))
}
)

Expand All @@ -288,7 +299,7 @@ resource "aws_lb" "load-balancer" {

name = "${var.tags.useCase}-${var.tags.owner}-lb"
internal = false
load_balancer_type = "application"
load_balancer_type = "network"
subnets = [aws_subnet.base-stack-public-subnet.id]
enable_deletion_protection = false

Expand Down
8 changes: 7 additions & 1 deletion Environments/AWS/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ variable "tags" {
description = "Tags to set on resources."
type = map(string)
default = {
owner : "Lantz"
owner : "User"
testing : "True"
okToRemove : "True"
useCase : "DevStack"
Expand Down Expand Up @@ -51,6 +51,12 @@ variable "ec2-username" {
default = "ubuntu"
}

variable "ec2-instance-type" {
type = string
default = "t4g.xlarge" //t4g.xlarge (ARM)
//default = "t3.xlarge" //"t3.xlarge" (x64)
}

variable "ingress_rules_from_trusted" {
description = "This will expose the coresponding ports to the internet, but limited to trusted-external-ips"
type = list(object({
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ This class will help you spin up JIRA and Bitbucket containers in the same docke
* DevStack is not intended for production use ever, it should only be used for short-lived test environments with nothing to loose.
* Not intended for existing environments, presumes DevStack was used to setup up the environment.

# Main building blocks and concepts

## Containers vs Deployments

The two main building blocks of DevStack are Containers and Deployments. A container is essentially just a representation of a normal Docker container, ie a pretty much a Docker Image that has been started with some added basic network and env-vars added. This is where Deployment then takes over and installs licenses, sets up database, admin accounts etc as many steps as possible to give you an environment ready for use.

## SubDeployments
SubDeployments are simply a collection of deployments used by a more complex deployment. [JenkinsAndHarborDeployment.groovy](src%2Fmain%2Fgroovy%2Fcom%2Feficode%2Fdevstack%2Fdeployment%2Fimpl%2FJenkinsAndHarborDeployment.groovy) for example uses the Jenkins and Harbor deployments as SubDeployments.

## Utils

These are classes mainly intended to be used by Container/Deployment-classes when massaging of the containers are needed for example. Currently [ImageBuilder.groovy](src%2Fmain%2Fgroovy%2Fcom%2Feficode%2Fdevstack%2Futil%2FImageBuilder.groovy) dynamically builds Atlassian images for non x86 architectures on the fly.

# Setup Docker Engine in AWS

DevStack defaults to trying to connect to a local Docker engine, but a terraform project is supplied for setting up a remote EC2 with docker engine. The docker engine will be configured to only accept HTTPS from your IP.
Expand Down Expand Up @@ -60,6 +73,19 @@ DevStack defaults to trying to connect to a local Docker engine, but a terraform

6. Go to Environments/Terraform and run terraform apply
* Note the "Hosts-record" output, this needs to be added to your /etc/hosts
* This host record should be considered a suggestion as it depends on things such as the base URLs you select for your deployments
7. Presuming everything was successful you should now be able to SSH to the new EC2 server and run commands such as "docker ps"
* If you have setup you hosts file according to the previous step, you should be able to ssh to docker.domain.se
8. Update your code, the Deployment and Container classes should all accept a docker host and cert path parameter
```groovy
String dockerRemoteHost = "https://docker.domain.se:2376"
String dockerCertPath = "~/.docker/"


//JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl) //If using a local docker engine
JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl, dockerRemoteHost, dockerCertPath) //If using a remote docker Engine

```


## Using DevStack in your project
Expand Down
25 changes: 22 additions & 3 deletions examples/Basic JSM Setup.groovy
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
@GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/')
@Grab(group = 'com.eficode', module = 'devstack', version = '2.2.0-SNAPSHOT-groovy-3.0.14', classifier = "standalone")
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test')
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)


import com.eficode.devstack.deployment.impl.JsmH2Deployment

String jiraBaseUrl = "http://localhost:8080"
JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl)

String dockerRemoteHost = "https://docker.domain.se:2376"
String dockerCertPath = "~/.docker/"

//Input JSM licence
String jsmLicense = """LICENSE GOES HERE"""

String jiraBaseUrl = "http://jira.localhost:8080"
JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl) //If using a local docker engine
//JsmH2Deployment jsmDep = new JsmH2Deployment("http://jira.domain.se:8080", dockerRemoteHost, dockerCertPath) //If using a remote docker Engine

File projectRoot = new File("../").canonicalFile

//Set JSM license that should be used
jsmDep.setJiraLicense(new File(projectRoot.path + "/resources/jira/licenses/jsm.license"))
jsmDep.setJiraLicense(jsmLicense)

//Set a container network
jsmDep.setDeploymentNetworkName("jsm")

//Optional settings
//jsmDep.jsmContainer.containerImageTag = "5.5.1" //Set docker image (and JSM) version
//jsmDep.jsmContainer.containerName = "Testing" //Set custom container name
//jsmDep.jsmContainer.jvmMaxRam = 4000 //Set max ram used by JSM
//jsmDep.appsToInstall = ["https://marketplace.atlassian.com/download/apps/6820/version/1005740":new File(projectRoot.path + "/resources/jira/licenses/scriptrunnerForJira.license").text]

//Stop and remove if already existing
jsmDep.stopAndRemoveDeployment()

jsmDep.setupDeployment()
45 changes: 45 additions & 0 deletions examples/Basic JSM and Bitbucket setup.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/')
@Grab(group = 'com.eficode', module = 'devstack', version = '2.2.0-SNAPSHOT-groovy-3.0.14', classifier = "standalone")
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test')
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)



import com.eficode.devstack.deployment.impl.JsmAndBitbucketH2Deployment

String dockerRemoteHost = "https://docker.domain.se:2376"
String dockerCertPath = "~/.docker/"

//Input licences
String jsmLicense = """LICENSE GOES HERE"""
String scriptRunnerLicense = """LICENSE GOES HERE"""
String bbLicense = """LICENSE GOES HERE"""

//Set application base urls
String jiraBaseUrl = "http://jira.localhost:8080"
String bbBaseUrl = "http://bitbucket.localhost:7990"

//Using local Docker engine
//Make sure these DNS names resolves to 127.0.0.1
JsmAndBitbucketH2Deployment jsmAndBb = new JsmAndBitbucketH2Deployment(jiraBaseUrl, bbBaseUrl)
//Using remote Docker Engine
//Make sure these DNS resolves
//JsmAndBitbucketH2Deployment jsmAndBb = new JsmAndBitbucketH2Deployment("http://jira.domain.se:8080", "http://bitbucket.domain.se:7990", dockerRemoteHost, dockerCertPath)


//Set JSM and Bitbucket license that should be used
jsmAndBb.setJiraLicense(jsmLicense)
jsmAndBb.setBitbucketLicense(bbLicense)

//Set the max ram per application, make sure your Docker engine is setup to support this
jsmAndBb.bitbucketContainer.setJvmMaxRam(4096)
jsmAndBb.jsmContainer.setJvmMaxRam(4096)

//Install JIRA App.
//ScriptRunner is needed for setting up application link between JIRA and Bitbucket
jsmAndBb.jiraAppsToInstall = ["https://marketplace.atlassian.com/download/apps/6820/version/1005740":scriptRunnerLicense]

//Stop and remove if already existing
jsmAndBb.stopAndRemoveDeployment()

jsmAndBb.setupDeployment()
38 changes: 25 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

<groupId>com.eficode</groupId>
<artifactId>devstack</artifactId>
<version>2.1.1-SNAPSHOT-groovy-${revision}</version>
<version>2.2.0-SNAPSHOT-groovy-${groovy.version}</version>
<packaging>jar</packaging>

<name>DevStack - Parent pom</name>
<name>DevStack</name>

<description>A series of scripts for setting up common developer application suites</description>

Expand All @@ -28,8 +28,8 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-yaml</artifactId>
<version>3.0.11</version>
<!--version>${groovy.version}</version-->
<!--version>3.0.11</version-->
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
Expand Down Expand Up @@ -255,28 +255,40 @@
</build>

<profiles>

<profile>
<id>groovy-3</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<groovy.major.version>3.0</groovy.major.version>
<groovy.version>3.0.11</groovy.version>
<groovy.version>3.0.14</groovy.version>
<spock-core.version>2.2-groovy-3.0</spock-core.version>
<jiraShortcuts.version>2.0.3-SNAPSHOT-groovy-3.0</jiraShortcuts.version>
<bitbucketinstancemanager.version>0.0.3-SNAPSHOT-groovy-3.0</bitbucketinstancemanager.version>
</properties>
</profile>


<profile>
<id>groovy-2.5</id>
<id>groovy-3.0.14</id>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<groovy.major.version>2.5</groovy.major.version>
<groovy.version>2.5.18</groovy.version>
<spock-core.version>2.2-groovy-2.5</spock-core.version>
<jiraShortcuts.version>2.0.3-SNAPSHOT-groovy-2.5</jiraShortcuts.version>
<bitbucketinstancemanager.version>0.0.3-SNAPSHOT-groovy-2.5</bitbucketinstancemanager.version>
<groovy.version>3.0.13</groovy.version>
</properties>
</profile>
<profile>
<id>groovy-3.0.12</id>
<properties>
<groovy.version>3.0.12</groovy.version>
</properties>
</profile>
<profile>
<id>groovy-3.0.11</id>
<properties>
<groovy.version>3.0.11</groovy.version>
</properties>
</profile>

Expand Down
Loading