Skip to content

Commit 2ebaf16

Browse files
authored
Merge pull request #6033 from gchq/5761-document-install-published
Issue 5761 - Document installing from published artefacts
2 parents b38a5ad + 738b54e commit 2ebaf16

File tree

6 files changed

+187
-462
lines changed

6 files changed

+187
-462
lines changed

docs/developer-guide.md

Lines changed: 11 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ work. Starting from the root of the Git repository:
116116
./scripts/build/buildForTest.sh
117117
```
118118

119+
You can disable building the Rust code by passing `-DskipRust` as an argument to that script. This can also be passed in
120+
any Maven build. This can speed up the build if you don't need the DataFusion data engine, or if you've already had a
121+
previous build that included Rust, skipping Rust will reuse the same binaries.
122+
123+
When running Maven directly, you can pass `-Pquick` to skip tests and linting.
124+
119125
### Sleeper CLI
120126

121127
To build the Sleeper CLI, you can run this script:
@@ -132,64 +138,11 @@ If you have the CLI installed already it will be replaced with the version that
132138
is different in the version you installed before, it will not be replaced. You can find it
133139
at `$HOME/.local/bin/sleeper`, and manually overwrite it with the contents of `./scripts/cli/runInDocker.sh`.
134140

135-
### Java
136-
137-
To build the Java code only, without installing it for the scripts:
138-
139-
```bash
140-
cd java
141-
mvn clean install -Pquick
142-
```
143-
144-
Removing the '-Pquick' option will cause the unit and integration tests to run.
145-
146-
### Disabling Rust component
147-
148-
You can disable the building of the Rust modules with:
149-
150-
```bash
151-
cd java
152-
mvn clean install -Pquick -DskipRust=true
153-
```
154-
155-
### Publishing Maven artifacts
156-
157-
There is a script [`scripts/dev/publishMaven.sh`](/scripts/dev/publishMaven.sh) to publish the Maven artifacts,
158-
including all modules and the fat jars used to deploy from and run scripts.
159-
160-
There is also a script [`scripts/dev/publishFatJars.sh`](/scripts/dev/publishFatJars.sh) to publish just the fat jars
161-
used for deployment and running scripts.
162-
163-
At some point one of these two will likely be removed.
164-
165-
The publishFatJars.sh version takes in two arguments:
166-
- The repository url to publish.
167-
- The ID of a server in a local m2 settings file which should contain authentication details.
141+
### Publishing artefacts
168142

169-
This can be tested locally by using a repository url similar to file:/path/to/output that will publish these files to the local file system.
170-
171-
The publishMaven.sh version accepts options to pass through to Maven, including `-DaltDeploymentRepository`, documented
172-
against [the Maven plugin](https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html). If you don't set a
173-
deployment repository it will publish the files to the local file system at `/tmp/sleeper/m2`.
174-
175-
To setup the local m2 settings file this guide can be followed: [Link to Baeldung](https://www.baeldung.com/maven-settings-xml#5-servers)
176-
177-
The development team are adding a way to retrieve and publish jars to AWS. Right now we only support deploying to AWS
178-
from jars that were built locally, but in the future you will be able to deploy jars from a Maven repository as well.
179-
180-
### Publishing Docker images
181-
182-
There is a script [`scripts/dev/publishDocker.sh`](/scripts/dev/publishDocker.sh) to publish the Docker images to a
183-
repository.
184-
185-
It takes in two arguments:
186-
* The repository prefix path.
187-
* An optional boolean to create the images that should be built for multiple platforms, this defaults to true.
188-
See [StackDockerImage.java](/java/clients/src/main/java/sleeper/clients/deploy/container/StackDockerImage.java) for more details.
189-
190-
The development team are adding a way to retrieve and publish Docker images to AWS. Right now we only support uploading
191-
the images to AWS if they were built locally, but in the future you will be able to upload images from an external
192-
repository as well.
143+
Tools are available to publish built artefacts to shared repositories, and to install them locally to avoid the need to
144+
build Sleeper yourself. We do not currently publish artefacts publicly.
145+
See [publishing artefacts](development/publishing.md) for how to set this up yourself.
193146

194147
## Using the codebase
195148

@@ -284,34 +237,4 @@ See the [release process guide](development/release-process.md) for instructions
284237

285238
## Development scripts
286239

287-
In the `/scripts/dev` folder are some scripts that can assist you while working on Sleeper:
288-
289-
#### `showInternalDependencies.sh`
290-
291-
This will display a graph of the dependencies between Sleeper's Maven modules. You can use this to explore how the
292-
modules relate to one another.
293-
294-
#### `generateDocumentation.sh`
295-
296-
This will regenerate the examples and templates for Sleeper configuration properties files. Use this if you've made any
297-
changes to Sleeper configuration properties. This will propagate any changes to property descriptions, ordering,
298-
grouping, etc.
299-
300-
#### `cleanupLogGroups.sh`
301-
302-
When deploying multiple instances (or running multiple system tests), many log groups will be generated. This can make
303-
it difficult to find the logs you need to view. This script will delete any log groups that meet all of the following
304-
criteria:
305-
306-
* Its name does not contain the name of any deployed CloudFormation stack
307-
* Either it's empty, or it has no retention period and is older than 30 days
308-
309-
This can be used to limit the number of log groups in your AWS account, particularly if all your log groups are
310-
deployed by the CDK or CloudFormation, with the stack name in the log group name.
311-
312-
Note that this will not delete log groups for recently deleted instances of Sleeper, so you will still need a different
313-
instance ID when deploying a new instance to avoid naming collisions with existing log groups.
314-
315-
#### `updateVersionNumber.sh`
316-
317-
This is used during the release process to update the version number across the project (see below).
240+
See [development scripts](development/dev-scripts.md) for scripts that can assist you while working on Sleeper.

docs/development/dev-scripts.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
## Development scripts
2+
3+
In the `/scripts/dev` folder are some scripts that can assist you while working on Sleeper:
4+
5+
#### `buildDockerImage.sh`
6+
7+
This will build a single Docker image, and can be used to prepare for execution of the local Docker image tests, e.g.
8+
`QueryLambdaDockerImageST`. You can run it like this:
9+
10+
```bash
11+
./scripts/dev/buildDockerImage.sh query-lambda test
12+
```
13+
14+
The first parameter is the name of the image, as listed in the documentation
15+
of [Docker images](../deployment/images-to-upload.md). The second parameter is the tag, usually "test" for an automated
16+
Docker image test.
17+
18+
#### `checkNotices.sh`
19+
20+
This will check whether all managed Maven dependencies have been included in the NOTICES file at the root of the
21+
repository.
22+
23+
#### `checkRustStyle.sh`
24+
25+
This runs linting on the Rust code.
26+
27+
#### `checkSpotBugs.sh`
28+
29+
This runs SpotBugs on specified Java modules. This is separated from the other linting as SpotBugs is quite slow.
30+
Here's an example of how to run it on multiple modules (note no spaces between the modules):
31+
32+
```bash
33+
./scripts/dev/checkSpotBugs.sh core,ingest/ingest-core
34+
```
35+
36+
#### `checkStyle.sh`
37+
38+
This runs linting on the Java code, except for SpotBugs as that is quite slow.
39+
40+
#### `cleanupLogGroups.sh`
41+
42+
When deploying multiple instances (or running multiple system tests), many log groups will be generated. This can make
43+
it difficult to find the logs you need to view. This script will delete any log groups that meet all of the following
44+
criteria:
45+
46+
* Its name does not contain the name of any deployed CloudFormation stack
47+
* Either it's empty, or it has no retention period and is older than 30 days
48+
49+
This can be used to limit the number of log groups in your AWS account, particularly if all your log groups are
50+
deployed by the CDK or CloudFormation, with the stack name in the log group name.
51+
52+
Note that this will not delete log groups for recently deleted instances of Sleeper, so you will still need a different
53+
instance ID when deploying a new instance to avoid naming collisions with existing log groups.
54+
55+
#### `copyRustToJava.sh`
56+
57+
This builds the Rust code and copies the binaries into the Maven project, so that the Rust code should be available
58+
when you run from inside your IDE. This is intended for use when running integration tests that call from Java into
59+
Rust.
60+
61+
#### `generateDocumentation.sh`
62+
63+
This will regenerate the examples and templates for Sleeper configuration properties files. Use this if you've made any
64+
changes to Sleeper configuration properties. This will propagate any changes to property descriptions, ordering,
65+
grouping, etc.
66+
67+
#### `publishDocker.sh`
68+
69+
Publishes Docker images to a remote repository, see [publishing artefacts](publishing.md).
70+
71+
#### `publishMaven.sh`
72+
73+
Publishes Maven artifacts to a remote repository, see [publishing artefacts](publishing.md).
74+
75+
#### `showInternalDependencies.sh`
76+
77+
This will display a graph of the dependencies between Sleeper's Maven modules. You can use this to explore how the
78+
modules relate to one another.
79+
80+
#### `updateVersionNumber.sh`
81+
82+
This is used during the release process to update the version number across the project, see
83+
the [release process guide](release-process.md).
84+
85+
#### `validateProjectChunks.sh`
86+
87+
Checks the configuration of the build for GitHub Actions. This compares `.github/config/chunks.yaml` against the Maven
88+
project and the GitHub Actions workflows under `.github/workflows/chunk-<id>.yaml`.
89+
90+
This is a split build where different Maven modules are built in different GitHub Actions workflows. Each workflow
91+
builds a single "chunk", with a number of modules. The `chunks.yaml` file defines the chunks, and therefore which
92+
modules should be built together in the same workflow.
93+
94+
This script checks that all Maven modules are included in the build. There are also build triggers that need to be hard
95+
coded in the GitHub Actions workflow. The script checks that triggers are set to run each workflow on any changes to
96+
files under its modules, or modules that they depend on.

docs/development/publishing.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Publishing artefacts
2+
====================
3+
4+
We have scripts to publish built artefacts to shared repositories, and to install them locally to avoid the need to
5+
build Sleeper yourself. We do not currently publish artefacts publicly.
6+
7+
### Publishing Maven artifacts
8+
9+
There is a script [`scripts/dev/publishMaven.sh`](/scripts/dev/publishMaven.sh) to publish the Maven artifacts,
10+
including all modules and the fat jars used to deploy from and run scripts.
11+
12+
This accepts options to pass through to Maven, including `-DaltDeploymentRepository`, documented
13+
against [the Maven plugin](https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html). If you don't set a
14+
deployment repository it will publish the files to the local file system at `/tmp/sleeper/m2`.
15+
16+
Here's an example of running this script:
17+
18+
```bash
19+
./scripts/dev/publishMaven.sh -DaltDeploymentRepository=my-repo-id::https://my.repository.com/path
20+
```
21+
22+
Your Maven settings file will need to have this repository declared, with a matching ID and any necessary
23+
authentication. Here's a guide to set this up: https://www.baeldung.com/maven-settings-xml#5-servers
24+
25+
This can be tested locally by using a repository url similar to file:/path/to/output that will publish these files to
26+
the local file system.
27+
28+
### Publishing Docker images
29+
30+
There is a script [`scripts/dev/publishDocker.sh`](/scripts/dev/publishDocker.sh) to publish the Docker images to a
31+
repository. It can be used like this:
32+
33+
```bash
34+
./scripts/dev/publishDocker.sh my.registry.com/path
35+
```
36+
37+
The first argument is the prefix that will begin each Docker image name. It should include the hostname and any path
38+
that you want to be used before the path component for each image. In this example images will be pushed like
39+
`my.registry.com/path/ingest`, `my.registry.com/path/query-lambda`.
40+
41+
You can pass an optional second argument for whether to create a new Docker builder. By default a Docker builder will be
42+
created that is capable of publishing multiplatform images, like this:
43+
44+
```bash
45+
docker buildx create --name sleeper --use
46+
```
47+
48+
This may not be suitable for all use cases. You can disable this by passing "false" as the second argument. In that
49+
case, you will need to ensure a Docker builder is set that can build multiplatform images before calling this script.
50+
51+
### Installing published artefacts
52+
53+
We have scripts to install Sleeper from published artefacts. We have not yet published Sleeper to Maven Central or
54+
Docker Hub. To install your own artefacts published as in the sections above, you can follow these steps:
55+
56+
1. Prepare a clone of this Git repository.
57+
2. Use `scripts/deploy/installJarsFromMaven.sh` to retrieve the jars from Maven.
58+
3. Use `scripts/deploy/setDeployFromRemoteDocker.sh` to configure the Sleeper scripts to pull published Docker images.
59+
4. Use the Sleeper scripts as though you had built from scratch.
60+
61+
The `installJarsFromMaven.sh` script can be used like this:
62+
63+
```bash
64+
./scripts/deploy/installJarsFromMaven.sh <version> ./scripts/jars -DremoteRepositories=my-repo-id::https://my.repository.com/path
65+
```
66+
67+
Your Maven settings file will need to have your repository declared, with a matching ID and any necessary
68+
authentication. Here's a guide to set this up: https://www.baeldung.com/maven-settings-xml#5-servers
69+
70+
The version must be the Maven version as it was in the Sleeper `java/pom.xml` when it was published to the repository.
71+
72+
The `setDeployFromRemoteDocker.sh` script can be used like this:
73+
74+
```bash
75+
./scripts/deploy/setDeployFromRemoteDocker.sh my.registry.com/path
76+
```
77+
78+
The argument to the script must be the prefix you used to publish the images. This script will create a configuration
79+
file under the templates directory that will adjust the way Docker images are pushed to AWS ECR during deployment, to
80+
pull them from your repository instead of building them locally.

0 commit comments

Comments
 (0)