Skip to content

Commit 56d5322

Browse files
authored
2.2.0 release (#16)
* main.tf * Added variable for EC2 instance type, to make it easier to switch between architectures. * Now selects AMI based on EC2 Architecture DoodContainer.groovy * Increased timeout for setup commands JsmContainer.groovy * Added getLatestJsmVersion() * Updated setupContainerCreateRequest() to support non x86 architectures DockerClientDS.groovy * Added getHost, getCertPath, getEngineArch ImageBuilder.groovy * A new util class/container for building docker images pom.xml * Bumped to 2.2.0 * BitbucketContainer.groovy * Added getLatestBbVersion() * Updated setupContainerCreateRequest() to support non x86 architectures ImageBuilder.groovy * Added buildBb * Basic JSM and Bitbukcet setup.groovy * Work in progress adding Grab dependencies GroovyDoodContainer.groovy * Work in progress, intended to test the library in a clean environment. Basic JSM Setup.groovy * Added documentation BitbucketContainer.groovy, JsmContainer.groovy * Now uses the images name instead of tag when creating containers with custom images DoodContainer.groovy * Now defaults to running commands as root JsmAndBitbucketH2Deployment.groovy * Fixed confusion related to setting licenses * Fixed false assertion error due to ScriptRunner not returning some logs * Added logging informing that an Application link was not created ImageBuilder.groovy * Now sets sensible container name so as to not conflict with parallel runs. * Removed a while statement that was not relevant. ExamplesTest.groovy * WIP, not working due to failing grab import README.md * Improved * Testing new workflow for buldinging jar Dropping Groovy 2 support * Basic JSM and Bitbucket setup.groovy and Basic JSM Setup.groovy * Added grab dependencies GroovyContainer.groovy * Now longer extends doodcontainer * runScriptInContainer now has options parameter ExamplesTest.groovy * WIP * Basic JSM and Bitbucket setup.groovy, Basic JSM Setup.groovy * Tweaked to be easier for users and spoc tests to run DevStackSpec.groovy * Added replaceVariableValue * BitbucketH2DeploymentTest.groovy JsmAndBitbucketH2DeploymentTest.groovy * Removed TODO that is no longer relevant.
1 parent eec05ff commit 56d5322

18 files changed

Lines changed: 665 additions & 66 deletions

.github/workflows/publish-maven-package.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ jobs:
3636
restore-keys: |
3737
${{ runner.os }}-maven-
3838
39-
- name: Installing Groovy 3 version
39+
- name: Compile and install locally
4040
run: |
4141
42-
4342
mkdir -p repository/com/eficode/devstack
44-
echo Compiling, Packaging and Installing Groovy 3.0 version of library to local m2 directory
45-
mvn install -P groovy-3 -DcreateChecksum=true -Drevision=3.0
4643
47-
48-
49-
- name: Installing Groovy 2.5 Version
50-
run: |
44+
mvn help:effective-pom -P groovy-3,groovy-3.0.14 -Doutput=effective-pom.xml
45+
mvn install -f effective-pom.xml -DcreateChecksum=true
46+
47+
mvn help:effective-pom -P groovy-3,groovy-3.0.13 -Doutput=effective-pom.xml
48+
mvn install -f effective-pom.xml -DcreateChecksum=true
5149
52-
echo Compiling, Packaging and Installing Groovy 2.5 version of library to local m2 directory
53-
mvn install -P groovy-2.5 -DcreateChecksum=true -Drevision=2.5
50+
mvn help:effective-pom -P groovy-3,groovy-3.0.12 -Doutput=effective-pom.xml
51+
mvn install -f effective-pom.xml -DcreateChecksum=true
5452
53+
mvn help:effective-pom -P groovy-3,groovy-3.0.11 -Doutput=effective-pom.xml
54+
mvn install -f effective-pom.xml -DcreateChecksum=true
5555
5656
- name: Copying JAR files
5757
run: |
@@ -78,7 +78,7 @@ jobs:
7878
echo Adding repository files to git
7979
git add repository/*
8080
echo Committing changes
81-
git commit -m "Updated packages to $VERSION"
81+
git commit -m "Updated packages"
8282
echo Pushing changes
8383
git push
8484

Environments/AWS/main.tf

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ data "aws_availability_zones" "available" {
6060
}
6161

6262

63+
data "aws_ec2_instance_type" "instance_type" {
64+
65+
instance_type = var.ec2-instance-type
66+
}
67+
68+
69+
6370
//Get the latest AmazoneLinux2 AMI
6471
data "aws_ami" "latest_amazon_linux_2" {
6572
most_recent = true
@@ -73,7 +80,7 @@ data "aws_ami" "latest_amazon_linux_2" {
7380
}
7481
filter {
7582
name = "architecture"
76-
values = ["x86_64"]
83+
values = data.aws_ec2_instance_type.instance_type.supported_architectures
7784
}
7885
owners = ["amazon"]
7986
}
@@ -84,14 +91,18 @@ data "aws_ami" "ubuntuAMI" {
8491

8592
filter {
8693
name = "name"
87-
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
94+
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-*-server-*"]
8895
}
8996

9097
filter {
9198
name = "virtualization-type"
9299
values = ["hvm"]
93100
}
94101

102+
filter {
103+
name = "architecture"
104+
values = data.aws_ec2_instance_type.instance_type.supported_architectures
105+
}
95106
owners = ["099720109477"] # Canonical
96107
}
97108

@@ -259,7 +270,7 @@ resource "aws_instance" "ec2-node" {
259270
}
260271

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

274285
user_data = templatefile("ubuntu_user_data.sh", {
275286
awsRegion : data.aws_region.current.name
276-
tlscacert : file(var.dockerServerCert.tlscacert)
277-
tlscert : file(var.dockerServerCert.tlscert)
278-
tlskey : file(var.dockerServerCert.tlskey)
287+
tlscacert : file(pathexpand(var.dockerServerCert.tlscacert))
288+
tlscert : file(pathexpand(var.dockerServerCert.tlscert))
289+
tlskey : file(pathexpand(var.dockerServerCert.tlskey))
279290
}
280291
)
281292

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

289300
name = "${var.tags.useCase}-${var.tags.owner}-lb"
290301
internal = false
291-
load_balancer_type = "application"
302+
load_balancer_type = "network"
292303
subnets = [aws_subnet.base-stack-public-subnet.id]
293304
enable_deletion_protection = false
294305

Environments/AWS/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ variable "tags" {
22
description = "Tags to set on resources."
33
type = map(string)
44
default = {
5-
owner : "Lantz"
5+
owner : "User"
66
testing : "True"
77
okToRemove : "True"
88
useCase : "DevStack"
@@ -51,6 +51,12 @@ variable "ec2-username" {
5151
default = "ubuntu"
5252
}
5353

54+
variable "ec2-instance-type" {
55+
type = string
56+
default = "t4g.xlarge" //t4g.xlarge (ARM)
57+
//default = "t3.xlarge" //"t3.xlarge" (x64)
58+
}
59+
5460
variable "ingress_rules_from_trusted" {
5561
description = "This will expose the coresponding ports to the internet, but limited to trusted-external-ips"
5662
type = list(object({

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ This class will help you spin up JIRA and Bitbucket containers in the same docke
2727
* DevStack is not intended for production use ever, it should only be used for short-lived test environments with nothing to loose.
2828
* Not intended for existing environments, presumes DevStack was used to setup up the environment.
2929

30+
# Main building blocks and concepts
31+
32+
## Containers vs Deployments
33+
34+
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.
35+
36+
## SubDeployments
37+
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.
38+
39+
## Utils
40+
41+
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.
42+
3043
# Setup Docker Engine in AWS
3144

3245
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.
@@ -60,6 +73,19 @@ DevStack defaults to trying to connect to a local Docker engine, but a terraform
6073

6174
6. Go to Environments/Terraform and run terraform apply
6275
* Note the "Hosts-record" output, this needs to be added to your /etc/hosts
76+
* This host record should be considered a suggestion as it depends on things such as the base URLs you select for your deployments
77+
7. Presuming everything was successful you should now be able to SSH to the new EC2 server and run commands such as "docker ps"
78+
* If you have setup you hosts file according to the previous step, you should be able to ssh to docker.domain.se
79+
8. Update your code, the Deployment and Container classes should all accept a docker host and cert path parameter
80+
```groovy
81+
String dockerRemoteHost = "https://docker.domain.se:2376"
82+
String dockerCertPath = "~/.docker/"
83+
84+
85+
//JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl) //If using a local docker engine
86+
JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl, dockerRemoteHost, dockerCertPath) //If using a remote docker Engine
87+
88+
```
6389

6490

6591
## Using DevStack in your project

examples/Basic JSM Setup.groovy

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1+
@GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/')
2+
@Grab(group = 'com.eficode', module = 'devstack', version = '2.2.0-SNAPSHOT-groovy-3.0.14', classifier = "standalone")
3+
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test')
4+
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)
5+
6+
17
import com.eficode.devstack.deployment.impl.JsmH2Deployment
28

3-
String jiraBaseUrl = "http://localhost:8080"
4-
JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl)
9+
10+
String dockerRemoteHost = "https://docker.domain.se:2376"
11+
String dockerCertPath = "~/.docker/"
12+
13+
//Input JSM licence
14+
String jsmLicense = """LICENSE GOES HERE"""
15+
16+
String jiraBaseUrl = "http://jira.localhost:8080"
17+
JsmH2Deployment jsmDep = new JsmH2Deployment(jiraBaseUrl) //If using a local docker engine
18+
//JsmH2Deployment jsmDep = new JsmH2Deployment("http://jira.domain.se:8080", dockerRemoteHost, dockerCertPath) //If using a remote docker Engine
19+
520
File projectRoot = new File("../").canonicalFile
621

722
//Set JSM license that should be used
8-
jsmDep.setJiraLicense(new File(projectRoot.path + "/resources/jira/licenses/jsm.license"))
23+
jsmDep.setJiraLicense(jsmLicense)
24+
25+
//Set a container network
26+
jsmDep.setDeploymentNetworkName("jsm")
927

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

34+
//Stop and remove if already existing
1635
jsmDep.stopAndRemoveDeployment()
1736

1837
jsmDep.setupDeployment()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/')
2+
@Grab(group = 'com.eficode', module = 'devstack', version = '2.2.0-SNAPSHOT-groovy-3.0.14', classifier = "standalone")
3+
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test')
4+
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)
5+
6+
7+
8+
import com.eficode.devstack.deployment.impl.JsmAndBitbucketH2Deployment
9+
10+
String dockerRemoteHost = "https://docker.domain.se:2376"
11+
String dockerCertPath = "~/.docker/"
12+
13+
//Input licences
14+
String jsmLicense = """LICENSE GOES HERE"""
15+
String scriptRunnerLicense = """LICENSE GOES HERE"""
16+
String bbLicense = """LICENSE GOES HERE"""
17+
18+
//Set application base urls
19+
String jiraBaseUrl = "http://jira.localhost:8080"
20+
String bbBaseUrl = "http://bitbucket.localhost:7990"
21+
22+
//Using local Docker engine
23+
//Make sure these DNS names resolves to 127.0.0.1
24+
JsmAndBitbucketH2Deployment jsmAndBb = new JsmAndBitbucketH2Deployment(jiraBaseUrl, bbBaseUrl)
25+
//Using remote Docker Engine
26+
//Make sure these DNS resolves
27+
//JsmAndBitbucketH2Deployment jsmAndBb = new JsmAndBitbucketH2Deployment("http://jira.domain.se:8080", "http://bitbucket.domain.se:7990", dockerRemoteHost, dockerCertPath)
28+
29+
30+
//Set JSM and Bitbucket license that should be used
31+
jsmAndBb.setJiraLicense(jsmLicense)
32+
jsmAndBb.setBitbucketLicense(bbLicense)
33+
34+
//Set the max ram per application, make sure your Docker engine is setup to support this
35+
jsmAndBb.bitbucketContainer.setJvmMaxRam(4096)
36+
jsmAndBb.jsmContainer.setJvmMaxRam(4096)
37+
38+
//Install JIRA App.
39+
//ScriptRunner is needed for setting up application link between JIRA and Bitbucket
40+
jsmAndBb.jiraAppsToInstall = ["https://marketplace.atlassian.com/download/apps/6820/version/1005740":scriptRunnerLicense]
41+
42+
//Stop and remove if already existing
43+
jsmAndBb.stopAndRemoveDeployment()
44+
45+
jsmAndBb.setupDeployment()

pom.xml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
<groupId>com.eficode</groupId>
88
<artifactId>devstack</artifactId>
9-
<version>2.1.1-SNAPSHOT-groovy-${revision}</version>
9+
<version>2.2.0-SNAPSHOT-groovy-${groovy.version}</version>
1010
<packaging>jar</packaging>
1111

12-
<name>DevStack - Parent pom</name>
12+
<name>DevStack</name>
1313

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

@@ -28,8 +28,8 @@
2828
<dependency>
2929
<groupId>org.codehaus.groovy</groupId>
3030
<artifactId>groovy-yaml</artifactId>
31-
<version>3.0.11</version>
32-
<!--version>${groovy.version}</version-->
31+
<!--version>3.0.11</version-->
32+
<version>${groovy.version}</version>
3333
</dependency>
3434
<dependency>
3535
<groupId>org.spockframework</groupId>
@@ -255,28 +255,40 @@
255255
</build>
256256

257257
<profiles>
258+
258259
<profile>
259260
<id>groovy-3</id>
261+
<activation>
262+
<activeByDefault>true</activeByDefault>
263+
</activation>
260264
<properties>
261265
<maven.compiler.source>11</maven.compiler.source>
262266
<maven.compiler.target>11</maven.compiler.target>
263267
<groovy.major.version>3.0</groovy.major.version>
264-
<groovy.version>3.0.11</groovy.version>
268+
<groovy.version>3.0.14</groovy.version>
265269
<spock-core.version>2.2-groovy-3.0</spock-core.version>
266270
<jiraShortcuts.version>2.0.3-SNAPSHOT-groovy-3.0</jiraShortcuts.version>
267271
<bitbucketinstancemanager.version>0.0.3-SNAPSHOT-groovy-3.0</bitbucketinstancemanager.version>
268272
</properties>
269273
</profile>
274+
275+
270276
<profile>
271-
<id>groovy-2.5</id>
277+
<id>groovy-3.0.14</id>
272278
<properties>
273-
<maven.compiler.source>11</maven.compiler.source>
274-
<maven.compiler.target>11</maven.compiler.target>
275-
<groovy.major.version>2.5</groovy.major.version>
276-
<groovy.version>2.5.18</groovy.version>
277-
<spock-core.version>2.2-groovy-2.5</spock-core.version>
278-
<jiraShortcuts.version>2.0.3-SNAPSHOT-groovy-2.5</jiraShortcuts.version>
279-
<bitbucketinstancemanager.version>0.0.3-SNAPSHOT-groovy-2.5</bitbucketinstancemanager.version>
279+
<groovy.version>3.0.13</groovy.version>
280+
</properties>
281+
</profile>
282+
<profile>
283+
<id>groovy-3.0.12</id>
284+
<properties>
285+
<groovy.version>3.0.12</groovy.version>
286+
</properties>
287+
</profile>
288+
<profile>
289+
<id>groovy-3.0.11</id>
290+
<properties>
291+
<groovy.version>3.0.11</groovy.version>
280292
</properties>
281293
</profile>
282294

0 commit comments

Comments
 (0)