Skip to content

Commit effd981

Browse files
authored
Merge pull request #129 from LandRegistry/develop
2.0
2 parents 66dfa60 + d408507 commit effd981

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+135
-947
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.vagrant/
21
.dev-env-context
32
.update-check-context
43
.quick-reload

README.md

+22-39
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,13 @@ It provides several hooks for applications to take advantage of, including:
1111

1212
### Prerequisites
1313

14-
#### Recommended setup
15-
1614
* **Docker and Docker Compose**. Exactly what toolset you use depends on your OS and personal preferences, but recommended are:
1715
* [Docker For Mac](https://docs.docker.com/docker-for-mac/)
1816
* [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)
1917
* [Docker CE for Linux](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
2018
* **Git**
2119
* **Ruby 2.5+**
2220

23-
#### Alternative setup
24-
25-
* **Vagrant** (v2+)
26-
* **VirtualBox** (v6+)
27-
28-
A Vagrantfile is provided so `vagrant up` will result in a virtual machine containing all the prerequisites from the Recommended setup above. From there, just `vagrant ssh` in and use the dev-env as you would natively.
29-
3021
### Git/SSH
3122

3223
You must ensure the shell you are starting the dev-env from can access all the necessary Git repositories - namely the config repo and the application repos it specifies. If they are to be accessed via SSH, [this wiki page](https://github.com/LandRegistry/common-dev-env/wiki/Git---SSH-setup) has some proven techniques for generating keys and making them available to the shell.
@@ -115,25 +106,21 @@ This file specifies which commodities the dev-env should create and launch for t
115106

116107
The list of allowable commodity values is:
117108

118-
1. postgres
119-
2. postgres-9.6
120-
3. postgres-13
121-
4. db2_devc (**Warning:** source image deprecated by IBM; use db2_community instead)
122-
5. db2_community
123-
6. elasticsearch
124-
7. elasticsearch5
125-
8. nginx
126-
9. rabbitmq
127-
10. redis
128-
11. swagger
129-
12. wiremock
130-
13. squid
131-
14. auth
132-
15. cadence
133-
16. cadence-web
134-
17. activemq
135-
18. ibmmq
136-
19. localstack
109+
1. postgres-13
110+
2. db2_community
111+
4. elasticsearch5
112+
5. nginx
113+
6. rabbitmq
114+
7. redis
115+
8. swagger
116+
9. wiremock
117+
10. squid
118+
11. auth
119+
12. cadence
120+
13. cadence-web
121+
14. activemq
122+
15. ibmmq
123+
16. localstack
137124

138125
* The file may optionally also indicate that one or more services are resource intensive ("expensive") when starting up. The dev env will start those containers seperately - 3 at a time - and wait until each are declared healthy (or crash and get restarted 10 times) before starting any more. This requires a healthcheck command specified here or in the Dockerfile/docker-compose-fragment (in which case just use 'docker' in this file).
139126
* If one of these expensive services prefers another one to be considered "healthy" before a startup attempt is made (such as a database, to ensure immediate connectivity and no expensive restarts) then the dependent service can be specified here, with a healthcheck command following the same rules as above.
@@ -156,35 +143,31 @@ If you want to spatially enable your database see the following example:
156143

157144
[Example - Spatial](snippets/spatial_postgres-init-fragment.sql)
158145

159-
The default Postgres port 5432 will be available for connections from other containers and on the host. Postgres 9.6 will be exposed on port 5433, Postgres 13 on 5434.
146+
The default Postgres port 5432 will be available for connections from other containers. Port 5434 is exposed for external connections from the host.
160147

161148
**`/manage.py`**
162149

163-
This is a standard Alembic management file - if it exists, then a database migration will be run on every `up` or `reload`. This can be disabled by setting the key `perform_alembic_migration` to `false` in `configuration.yml` - for example if the file does not actually relate to Alembic, or you do your own migration during app startup.
164-
165-
##### DB2
150+
This is a standard Alembic management file - if it exists, then a database migration will be run on every `up` or `reload`. This functionality can be enabled by setting the key `perform_alembic_migration` to `true` in `configuration.yml`. It is recommended however that you do your own migration during app startup.
166151

167-
`db2_community` (DB2 Community Edition 11.5) is recommended over `db2_devc` (DB2 Developer C 11.0)
152+
##### DB2 Community
168153

169-
Note that DB2 Developer C is exposed on the host ports 50001/55001 and DB2 Community on 50002/55002 to avoid port clashes.
154+
Note that DB2 Community is exposed on 30002/35002 to avoid port clashes.
170155

171-
**`/fragments/db2-devc-init-fragment.sql`**
172156
**`/fragments/db2-community-init-fragment.sql`**
173157

174158
This file contains any one-off SQL to run in DB2 - at the minimum it will normally be creating a database.
175159

176160
[Example](snippets/db2-community-init-fragment.sql)
177161

178-
##### ElasticSearch
162+
##### ElasticSearch 5
179163

180-
**`/fragments/elasticsearch-fragment.sh`**
181164
**`/fragments/elasticsearch5-fragment.sh`**
182165

183166
This file is a shell script that contains curl commands to do any setup the app needs in elasticsearch - creating indexes etc. It will be passed a single argument, the host and port, which can be accessed in the script using `$1`.
184167

185-
The ports 9200/9300 and 9202/9302 are exposed on the host for Elasticsearch versions 2 and 5 respectively.
168+
The ports 9300 and 9302 are exposed on the host.
186169

187-
[Example](snippets/elasticsearch-fragment.sh)
170+
[Example](snippets/elasticsearch5-fragment.sh)
188171

189172
##### Nginx
190173

Vagrantfile

-127
This file was deleted.

logic.rb

+7-11
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
root_loc = __dir__
3030

3131
# Define the DEV_ENV_CONTEXT_FILE file name to store the users app_grouping choice
32-
# As vagrant up can be run from any subdirectory, we must make sure it is stored alongside the Vagrantfile
3332
DEV_ENV_CONTEXT_FILE = root_loc + '/.dev-env-context'
3433

3534
# Where we clone the dev env configuration repo into
@@ -76,7 +75,7 @@
7675

7776
# Does a version check and self-update if required
7877
if options['self_update']
79-
this_version = '1.21.2'
78+
this_version = '2.0.0'
8079
puts colorize_lightblue("This is a universal dev env (version #{this_version})")
8180
# Skip version check if not on master (prevents infinite loops if you're in a branch that isn't up to date with the
8281
# latest release code yet)
@@ -117,7 +116,7 @@
117116
# Then use that config to clone/update apps, create commodities and custom provision lists
118117
# and download supporting files
119118
if options['prepare_config']
120-
# Check if a DEV_ENV_CONTEXT_FILE exists, to prevent prompting for dev-env configuration choice on each vagrant up
119+
# Check if a DEV_ENV_CONTEXT_FILE exists, to prevent prompting for dev-env configuration choice on each up
121120
if File.exist?(DEV_ENV_CONTEXT_FILE)
122121
puts ''
123122
puts colorize_green("This dev env has been provisioned to run for the repo: #{File.read(DEV_ENV_CONTEXT_FILE)}")
@@ -197,16 +196,13 @@
197196
puts colorize_lightblue('Building images...')
198197
# v2 already builds in parallel
199198
if ENV['DC_VERSION'] == '2'
200-
if run_command("#{ENV['DC_CMD']} build --memory 384m " + (options['nopull'] ? '' : '--pull')) != 0
201-
puts colorize_yellow('Build command failed. Trying without a memory limit')
202-
if run_command("#{ENV['DC_CMD']} build " + (options['nopull'] ? '' : '--pull')) != 0
203-
puts colorize_red('Something went wrong when building your app images. Check the output above.')
204-
exit
205-
end
199+
if run_command("#{ENV['DC_CMD']} build " + (options['nopull'] ? '' : '--pull')) != 0
200+
puts colorize_red('Something went wrong when building your app images. Check the output above.')
201+
exit
206202
end
207203
else
208-
if run_command("#{ENV['DC_CMD']} build --memory 384m --parallel " + (options['nopull'] ? '' : '--pull')) != 0
209-
puts colorize_yellow('Build command failed. Trying without --parallel and no memory limit')
204+
if run_command("#{ENV['DC_CMD']} build --parallel " + (options['nopull'] ? '' : '--pull')) != 0
205+
puts colorize_yellow('Build command failed. Trying without --parallel')
210206
# Might not be running a version of compose that supports --parallel, try one more time
211207
if run_command("#{ENV['DC_CMD']} build " + (options['nopull'] ? '' : '--pull')) != 0
212208
puts colorize_red('Something went wrong when building your app images. Check the output above.')

run.sh

+8-12
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,17 @@ then
4242
echo -e "\e[36mBeginning UP\e[0m"
4343
ruby logic.rb --check-for-update --prepare-config --update-apps --prepare-compose "${subcommands}" &&
4444
source scripts/docker_prepare.sh &&
45-
ruby logic.rb --build-images --provision-commodities --start-apps "${subcommands}" &&
46-
source scripts/after-ups.sh &&
47-
source scripts/add-aliases.sh
45+
source scripts/add-aliases.sh &&
46+
ruby logic.rb --build-images --provision-commodities --start-apps "${subcommands}"
4847
fi
4948

5049
if [ "$command" = "quickup" ]
5150
then
5251
echo -e "\e[36mBeginning UP (Quick mode)\e[0m"
5352
ruby logic.rb --check-for-update --prepare-compose &&
5453
source scripts/docker_prepare.sh &&
55-
ruby logic.rb --start-apps &&
56-
source scripts/after-ups.sh &&
57-
source scripts/add-aliases.sh
54+
source scripts/add-aliases.sh &&
55+
ruby logic.rb --start-apps
5856
fi
5957

6058
if [ "$command" = "halt" ]
@@ -75,9 +73,8 @@ then
7573
source scripts/docker_prepare.sh &&
7674
ruby logic.rb --stop-apps --prepare-config --update-apps --prepare-compose "${subcommands}" &&
7775
source scripts/docker_prepare.sh &&
78-
ruby logic.rb --build-images --provision-commodities --start-apps "${subcommands}" &&
79-
source scripts/after-ups.sh &&
80-
source scripts/add-aliases.sh
76+
source scripts/add-aliases.sh &&
77+
ruby logic.rb --build-images --provision-commodities --start-apps "${subcommands}"
8178
fi
8279

8380
if [ "$command" = "quickreload" ]
@@ -87,9 +84,8 @@ then
8784
source scripts/docker_prepare.sh &&
8885
ruby logic.rb --stop-apps --prepare-compose &&
8986
source scripts/docker_prepare.sh &&
90-
ruby logic.rb --start-apps &&
91-
source scripts/after-ups.sh &&
92-
source scripts/add-aliases.sh
87+
source scripts/add-aliases.sh &&
88+
ruby logic.rb --start-apps
9389
fi
9490

9591
if [ "$command" = "destroy" ]

scripts/add-aliases.sh

+2-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ alias livelogs="docker attach --no-stdin --sig-proxy=false"
1515
alias ex="$DC_CMD exec"
1616
alias status="$DC_CMD ps"
1717
alias run="$DC_CMD run --rm"
18-
alias psql="$DC_CMD exec postgres psql -h postgres -U root -d"
19-
alias db2="$DC_CMD exec --user db2inst1 db2 bash -c '~/sqllib/bin/db2'"
20-
alias psql96="$DC_CMD exec postgres-96 psql -h postgres-96 -U root -d"
2118
alias psql13="$DC_CMD exec postgres-13 psql -h postgres-13 -U root -d"
22-
alias db2c="$DC_CMD exec --user db2inst1 db2_devc bash -c '~/sqllib/bin/db2'"
2319
alias db2co="$DC_CMD exec --user db2inst1 db2_community bash -c '~/sqllib/bin/db2'"
2420
alias gitlist="bash $DEV_ENV_ROOT_DIR/scripts/git_list.sh"
2521
alias gitpull="bash $DEV_ENV_ROOT_DIR/scripts/git_pull.sh"
@@ -215,8 +211,8 @@ function devenv-help(){
215211
if you add -r it will output reports to the test-output folder
216212
if you add -f it will automatically fix issues where possible
217213
(flags can be combined)
218-
psql[96] <name of database> - run psql in the postgres/postgres-96 container
219-
db2[c][co] - run db2 command line in the db2/db2_devc/db2_community container
214+
psql13 <name of database> - run psql in the postgres-13 container
215+
db2co - run db2 command line in the db2_community container
220216
manage <name of container> <command> - run manage.py commands in a container
221217
alembic <name of container> <command> - run an alembic db command in a container, with the appropriate environment variables preset
222218
add-to-docker-compose

scripts/after-ups.sh

-28
This file was deleted.

0 commit comments

Comments
 (0)