Skip to content

Commit 5b81ae7

Browse files
authored
Merge branch 'LandRegistry:master' into feature/valkey-commodity
2 parents 0fcf990 + a49a68d commit 5b81ae7

40 files changed

+183
-204
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.5
2+
TargetRubyVersion: 3.0
33

44
Exclude:
55
- "apps/**/*"

CODE_OF_CONDUCT.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
- Using welcoming and inclusive language
12+
- Being respectful of differing viewpoints and experiences
13+
- Gracefully accepting constructive criticism
14+
- Focusing on what is best for the community
15+
- Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
- Trolling, insulting/derogatory comments, and personal or political attacks
21+
- Public or private harassment
22+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
- Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
34+
35+
Representation of a project may be further defined and clarified by project maintainers.
36+
37+
## Enforcement
38+
39+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances.
40+
41+
The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
42+
43+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
44+
45+
## Attribution
46+
47+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
48+
49+
[homepage]: http://contributor-covenant.org
50+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
When contributing to this repository, please first discuss the change you wish to make via issue, email or any other method with the owners of this repository before making a change.
44

5-
Please note we have a code of conduct, please follow it in all your interactions with the project.
5+
Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
66

77
## Making a change
88

@@ -12,55 +12,8 @@ Please use the `develop` branch as starting point for your own branch, and the t
1212

1313
If you're adding a commodity, at the very minimum it will need a `compose-fragment.yml` and a README entry. If there is support for extra functionality such as provisioning snippets, then a working example should be placed in the snippets directory and linked to from the README.
1414

15-
## Code of Conduct
15+
It is preferred that base images come from container registries other than Docker Hub where possible to avoid users being adversely affected by pull limits (alternatives include [quay.io](https://quay.io) and [Amazon ECR](https://public.ecr.aws)),
16+
but only where an official image exists in those locations. If an official image only exists in Docker Hub, then use the Docker Hub image. Care should always be taken when referencing third-party base images from any container registry.
1617

17-
### Our Pledge
18-
19-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
20-
21-
### Our Standards
22-
23-
Examples of behavior that contributes to creating a positive environment include:
24-
25-
- Using welcoming and inclusive language
26-
- Being respectful of differing viewpoints and experiences
27-
- Gracefully accepting constructive criticism
28-
- Focusing on what is best for the community
29-
- Showing empathy towards other community members
30-
31-
Examples of unacceptable behavior by participants include:
32-
33-
- The use of sexualized language or imagery and unwelcome sexual attention or advances
34-
- Trolling, insulting/derogatory comments, and personal or political attacks
35-
- Public or private harassment
36-
- Publishing others' private information, such as a physical or electronic address, without explicit permission
37-
- Other conduct which could reasonably be considered inappropriate in a professional setting
38-
39-
### Our Responsibilities
40-
41-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
42-
43-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
44-
45-
### Scope
46-
47-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
48-
49-
Representation of a project may be further defined and clarified by project maintainers.
50-
51-
### Enforcement
52-
53-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances.
54-
55-
The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
56-
57-
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
58-
59-
### Attribution
60-
61-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
62-
63-
[homepage]: http://contributor-covenant.org
64-
[version]: http://contributor-covenant.org/version/1/4/
6518
[how-to-contribute]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github
6619
[first-timers]: http://www.firsttimersonly.com/

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ It provides several hooks for applications to take advantage of, including:
1212
### Prerequisites
1313

1414
- **Docker and Docker Compose**. Exactly what toolset you use depends on your OS and personal preferences, but recommended are:
15-
- [Docker For Mac](https://docs.docker.com/docker-for-mac/)
16-
- [Docker for Windows 10](https://docs.docker.com/docker-for-windows/) (See [the wiki](https://github.com/LandRegistry/common-dev-env/wiki/Windows-setup) for more information on getting a working Windows environment set up)
15+
- [Docker Desktop](https://docs.docker.com/desktop/)
1716
- [Docker CE for Linux](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
1817
- **Git**
19-
- **Ruby 2.5+**
18+
- **Ruby 3.0+**
2019

2120
### Git/SSH
2221

@@ -33,17 +32,19 @@ To begin:
3332

3433
**TIP:** You can add a # onto the end of the configuration repository location followed by a branch, tag or commit you want to check out, if the default branch is not good enough.
3534

35+
**TIP:** You can specify 'local' to manage your application list without relying on an external Git repository. This is useful when you want complete control over your configuration or are working on a new service that does not have a remote config repo yet. A default `dev-env-config/configuration.yml` will be created for you. You can then manually add applications to that list.
36+
3637
Other `run.sh` parameters are:
3738

3839
- `halt` - stops all containers
3940
- `reload` - stops all containers then rebuilds and restarts them (including running any commodity fragments)
40-
- `destroy` - stops/removes all containers, removes all built images (i.e. leaving any pulled from Docker Hub) and resets all dev-env configuration files.
41+
- `destroy` - stops/removes all containers, removes all built images (i.e. leaving any pulled from external container registries) and resets all dev-env configuration files.
4142
- `repair` - sets the Docker-compose configuration to use the fragments from applications in _this_ dev-env instance (in case you are switching between several or are in a different terminal window to the one you ran `up` in)
4243
- `quickup` and `quickreload` - as per `up` and `reload` except they do not update anything from git (apps or config), rebuild Docker images or provision any commodity fragments.
4344

4445
#### Extra functionality
4546

46-
- `--nopull` (or `-n`) can go after `up` or `reload` - e.g. `source run.sh up -n`. This will stop images FROMed in Dockerfiles being checked for updates if a copy already exists on the system. Use to avoid Docker Hub pull rate limits.
47+
- `--nopull` (or `-n`) can go after `up` or `reload` - e.g. `source run.sh up -n`. This will stop images FROMed in Dockerfiles being checked for updates if a copy already exists on the system. Use to avoid container registry pull rate limits.
4748

4849
## Usage guide
4950

@@ -366,10 +367,6 @@ This file contains details of hosts to be forwarded on the host; if it exists th
366367

367368
[Example](snippets/host-fragments.yml)
368369

369-
**`/fragments/docker-compose-<any value>-fragment.yml`**
370-
371-
This file can be used to override the default settings for a docker container such as environment variables. It will not be loaded by default but can be applied using the add-to-docker-compose alias.
372-
373370
## Logging
374371

375372
Any messages that get forwarded to the logstash\* container on TCP port 25826 will be output both in the logstash container's own stdout (so `livelogs logstash` can be used to monitor all apps) and in ./logs/log.txt.

SECURITY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# HM Land Registry Security and Vulnerability Reporting Policy
2+
3+
This repository follows HM Land Registry's [reporting policy][policy] for reporting vulnerabilities that affect HM Land Registry services and systems. All persons disclosing vulnerabilities that affect this repository are requested to follow this policy when reporting.
4+
5+
Do not raise public issues or pull requests for any vulnerabilities affecting HM Land Registry services and systems.
6+
7+
[policy]: https://www.gov.uk/guidance/report-a-vulnerability-on-an-hm-land-registry-service-or-system

logfiles/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.log

logic.rb

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
# Does a version check and self-update if required
7777
if options['self_update']
78-
this_version = '2.4.0'
78+
this_version = '3.0.0'
7979
puts colorize_lightblue("This is a universal dev env (version #{this_version})")
8080
# Skip version check if not on master (prevents infinite loops if you're in a branch that isn't up to date with the
8181
# latest release code yet)
@@ -124,21 +124,34 @@
124124
File.open(DEV_ENV_CONTEXT_FILE, 'w+') { |file| file.write(config_repo) }
125125
end
126126

127+
config_repo = File.read(DEV_ENV_CONTEXT_FILE).strip
127128
# Check if dev-env-config exists, and if so pull the dev-env configuration. Otherwise clone it.
128-
puts colorize_lightblue('Retrieving custom configuration repo files:')
129129
if Dir.exist?(DEV_ENV_CONFIG_DIR)
130130
new_project = false
131-
command_successful = run_command("git -C #{root_loc}/dev-env-config pull")
131+
command_successful = if config_repo == 'local'
132+
0
133+
else
134+
run_command("git -C #{root_loc}/dev-env-config pull")
135+
end
132136
else
133137
new_project = true
134-
config_repo = File.read(DEV_ENV_CONTEXT_FILE)
135138
parsed_repo, delimiter, ref = config_repo.rpartition('#')
136139
# If they didn't specify a #ref, rpartition returns "", "", wholestring
137140
parsed_repo = ref if delimiter.empty?
138-
command_successful = run_command("git clone #{parsed_repo} #{root_loc}/dev-env-config")
139-
if command_successful.zero? && !delimiter.empty?
140-
puts colorize_lightblue("Checking out configuration repo ref: #{ref}")
141-
command_successful = run_command("git -C #{root_loc}/dev-env-config checkout #{ref}")
141+
if config_repo == 'local'
142+
puts colorize_lightblue('Initializing local config repository.')
143+
run_command("mkdir #{DEV_ENV_CONFIG_DIR}")
144+
# Create a configuration.yml with an empty services array
145+
File.open("#{DEV_ENV_CONFIG_DIR}/configuration.yml", 'w') do |file|
146+
file.write("---\nservices: {}\n")
147+
end
148+
puts colorize_green("You can start adding apps to #{DEV_ENV_CONFIG_DIR}/configuration.yml")
149+
exit 1
150+
else
151+
command_successful = run_command("git clone #{parsed_repo} #{DEV_ENV_CONFIG_DIR}")
152+
if command_successful.zero? && !delimiter.empty?
153+
command_successful = run_command("git -C #{DEV_ENV_CONFIG_DIR} checkout #{ref}")
154+
end
142155
end
143156
end
144157

@@ -177,11 +190,9 @@
177190
# TODO bash autocompletion of container names
178191
if options['prepare_compose']
179192
# Create a file called .commodities.yml with the list of commodities in it
180-
puts colorize_lightblue('Creating list of commodities')
181193
create_commodities_list(root_loc)
182194

183195
# Call the ruby function to create the docker compose file containing the apps and their commodities
184-
puts colorize_lightblue('Creating docker-compose file list')
185196
prepare_compose(root_loc, DOCKER_COMPOSE_FILE_LIST)
186197
end
187198

@@ -191,24 +202,28 @@
191202
exit
192203
end
193204

194-
puts colorize_lightblue('Building images...')
195-
if run_command("#{ENV['DC_CMD']} build " + (options['nopull'] ? '' : '--pull')) != 0
196-
puts colorize_red('Something went wrong when building your app images. Check the output above.')
205+
puts colorize_lightblue('Building images (might take a while)... (logging to logfiles/imagebuild.log)')
206+
if run_command("#{ENV['DC_CMD']} build #{options['nopull'] ? '' : '--pull'} > logfiles/imagebuild.log 2>&1") != 0
207+
puts colorize_red('Something went wrong when building the images, check the log file. Here are the last 10 lines:')
208+
lines = File.readlines("#{root_loc}/logfiles/imagebuild.log")
209+
last_ten = lines.last(10)
210+
last_ten.each { |line| puts line }
197211
exit
198212
end
199-
200213
end
201214

202215
if options['provision_commodities']
203216
# Before creating any containers, let's see what already exists (in case we need to override provision status)
204217
existing_containers = []
205-
# v2 --services seems to work differently. it already excludes deleted containers
206218
run_command("#{ENV['DC_CMD']} ps --services", existing_containers)
207219

208220
# Let's force a recreation of the containers here so we know they're using up-to-date images
209-
puts colorize_lightblue('Creating containers...')
210-
if run_command("#{ENV['DC_CMD']} up --remove-orphans --force-recreate --no-start") != 0
211-
puts colorize_red('Something went wrong when creating your app containers. Check the output above.')
221+
puts colorize_lightblue('Recreating containers... (logging to logfiles/containercreate.log)')
222+
if run_command("#{ENV['DC_CMD']} up --remove-orphans --force-recreate --no-start > logfiles/containercreate.log 2>&1") != 0
223+
puts colorize_red('Something went wrong when creating the containers, check the log file. Here are the last 10 lines:')
224+
lines = File.readlines("#{root_loc}/logfiles/containercreate.log")
225+
last_ten = lines.last(10)
226+
last_ten.each { |line| puts line }
212227
exit
213228
end
214229

@@ -239,6 +254,7 @@
239254
# The list of expensive services currently starting
240255
expensive_inprogress = []
241256

257+
puts colorize_lightblue('Checking application configurations...')
242258
config['applications'].each do |appname, appconfig|
243259
# First, special options check (in the dev-env-config)
244260
# for any settings that should override what the app wants to do
@@ -274,26 +290,30 @@
274290
end
275291
end
276292

277-
puts colorize_lightblue('Starting log receiver service...')
278-
up = run_command("#{ENV['DC_CMD']} up --no-deps --remove-orphans -d logstash")
293+
up = run_command("#{ENV['DC_CMD']} up --no-deps --remove-orphans -d logstash", [])
279294
sleep(3)
280295
if up != 0
281-
puts colorize_red('Something went wrong when initialising logging. Check the output above.')
296+
puts colorize_red('Something went wrong when initialising live container logging. Check the output above.')
282297
exit
283298
end
284299

285300
# Now we can start inexpensive apps, which should be quick and easy
286301
if services_to_start.any?
287-
puts colorize_lightblue('Starting inexpensive services...')
288-
up = run_command("#{ENV['DC_CMD']} up --no-deps --remove-orphans -d " + services_to_start.join(' '))
302+
puts colorize_lightblue('Starting inexpensive services... (logging to logfiles/containerstart.log)')
303+
up = run_command("#{ENV['DC_CMD']} up --no-deps --remove-orphans -d #{services_to_start.join(' ')}")
289304
if up != 0
290-
puts colorize_red('Something went wrong when creating your app images or containers. Check the output above.')
305+
puts colorize_red('Something went wrong when starting the containers, check the log file. Here are the last 10 lines:')
306+
lines = File.readlines("#{root_loc}/logfiles/containerstart.log")
307+
last_ten = lines.last(10)
308+
last_ten.each { |line| puts line }
291309
exit
292310
end
293311
end
294312

295313
# Until we have no more left to start AND we have no more in progress...
296-
puts colorize_lightblue('Starting expensive services...') if expensive_todo.length.positive?
314+
if expensive_todo.length.positive?
315+
puts colorize_lightblue('Starting expensive services... (logging to logfiles/containerstart.log)')
316+
end
297317
expensive_failed = []
298318
while expensive_todo.length.positive? || expensive_inprogress.length.positive?
299319
# Wait for a bit before the next round of checks
@@ -405,7 +425,7 @@
405425
puts colorize_yellow(" #{service['compose_service']}")
406426
end
407427
else
408-
puts colorize_green('All done, environment is ready for use')
428+
puts colorize_green('Environment is ready for use')
409429
end
410430

411431
post_up_message = config.fetch('post-up-message', nil)

scripts/add-aliases.sh

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,6 @@ function alembic(){
168168
bash -c 'cd /src && python3 manage.py db '"${@:2}"''
169169
}
170170

171-
function add-to-docker-compose(){
172-
COMPOSE_FILE_LIST=$(printenv COMPOSE_FILE)
173-
IFS=':' read -r -a array <<< "$COMPOSE_FILE_LIST"
174-
for element in "${array[@]}"
175-
do
176-
if [ -f ${element%/*}/docker-compose-${1}-fragment.yml ]; then
177-
COMPOSE_FILE_LIST="$COMPOSE_FILE_LIST:${element%/*}/docker-compose-${1}-fragment.yml"
178-
fi
179-
done
180-
export COMPOSE_FILE=$COMPOSE_FILE_LIST
181-
alias test="$DC_CMD up -d"
182-
test
183-
}
184-
185171
function devenv-help(){
186172
cat <<EOF
187173
If typing a docker-compose command you can use the alias dc instead. For example "dc ps" rather than "docker-compose ps".

0 commit comments

Comments
 (0)