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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ The list of allowable commodity values is:
20. prometheus
21. grafana
22. govuk-one-login
23. floci

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.

Expand Down Expand Up @@ -390,6 +391,16 @@ The GOV.UK One Login simulator is a development tool that lets you run end-to-en

See [documentation](https://github.com/govuk-one-login/simulator).

###### floci
Comment thread
Phemus marked this conversation as resolved.
Resolved

**`/fragments/floci-init-fragment.sh`**

[Floci](https://floci.io/) is a cloud stack testing and mocking framework for developing against various AWS services.

For any configuration (such as new buckets) necessary before application startup, you can use a `floci-init-fragment.sh` to perform this provisioning; like [this example](snippets/floci-init-fragment.sh). Floci provisioning is performed using the aws cli.

Floci is available at <http://floci:4566> within the Docker network, and <http://localhost:4566> on the host.

#### Other files

**`/fragments/custom-provision.sh`**
Expand Down
3 changes: 3 additions & 0 deletions scripts/commodities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require_relative 'provision_elasticsearch7'
require_relative 'provision_wiremock'
require_relative 'provision_localstack'
require_relative 'provision_floci'

require 'fileutils'
require 'open3'
Expand Down Expand Up @@ -150,6 +151,8 @@ def provision_commodities(root_loc, new_containers)
provision_hosts(root_loc)
# Localstack
provision_localstack(root_loc, new_containers)
# floci
provision_floci(root_loc, new_containers)
end

def container_to_commodity(container_name)
Expand Down
6 changes: 6 additions & 0 deletions scripts/docker/floci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM floci/floci:2.3.0-compat@sha256:ecfd33bb98d3e0ce0e11d528730f0827c08ab18c9b331865203d67ec65c10c07

ENV AWS_ENDPOINT_URL=http://floci:4566 \
AWS_DEFAULT_REGION=us-east-1 \
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test
7 changes: 7 additions & 0 deletions scripts/docker/floci/compose-fragment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
# Notice how the service name, container name and repo directory (where the Dockerfile lives) all match.
floci:
container_name: floci
build: ../scripts/docker/floci/
ports:
- 4566:4566
73 changes: 73 additions & 0 deletions scripts/provision_floci.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require_relative 'utilities'
require_relative 'commodities'
require 'yaml'

def provision_floci(root_loc, new_containers)
# Load configuration.yml into a Hash
config = YAML.load_file("#{root_loc}/dev-env-config/configuration.yml")
return unless config['applications']

# Did the container previously exist, if not then we MUST provision regardless of .commodities value
new_container = false
if new_containers.include?('floci')
new_container = true
puts colorize_yellow('The Floci container has been newly created - '\
'provision status in .commodities will be ignored')
end

floci_initialised = false

config['applications'].each_key do |appname|
# To help enforce the accuracy of the app's dependency file, only search for init script
# if the app specifically specifies floci in it's commodity list
next unless File.exist?("#{root_loc}/apps/#{appname}/configuration.yml")
next unless commodity_required?(root_loc, appname, 'floci')

# Load any init fragments contained in the apps into the docker commands list
if File.exist?("#{root_loc}/apps/#{appname}/fragments/floci-init-fragment.sh")
process_floci_fragment(root_loc, appname, floci_initialised, new_container)
end
end
end

def process_floci_fragment(root_loc, appname, floci_initialised, new_container)
result = floci_initialised
puts colorize_pink("Found a Floci init fragment in #{appname}")
if commodity_provisioned?(root_loc, appname, 'floci') && !new_container
puts colorize_yellow("Floci has previously been provisioned for #{appname}, skipping")
else
unless floci_initialised
init_floci
result = true
end
init_floci_sh(root_loc, appname)
end
result
end

def init_floci_sh(root_loc, appname)
# See comments in provision_postgres.rb for why we are doing it this way
run_command('tar -c' \
" -C #{root_loc}/apps/#{appname}/fragments" \
' floci-init-fragment.sh' \
' | docker cp - floci:/')

cmd = 'docker exec floci bash -c "sh /floci-init-fragment.sh"'
exit_code = run_command(cmd)

puts colorize_lightblue("Completed #{appname} Floci fragment")

if ![0].include?(exit_code)
# if exit_code != 0
puts colorize_red("Something went wrong with the Floci setup. Exitcode - #{exit_code}")
else
puts colorize_yellow("Floci initialised correctly. Exitcode - #{exit_code}.")
set_commodity_provision_status(root_loc, appname, 'floci', true)
end
end

def init_floci
# Start floci
run_command("#{ENV['DC_CMD']} up -d floci")
puts colorize_green('Floci is ready')
end
6 changes: 3 additions & 3 deletions scripts/update_apps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def update_app(appconfig, root_loc, appname)
output_lines
).zero?
return (
# Attempt to merge our remote branch into our local branch, if it's straightforward
output_lines += merge(root_loc, appname)
)
# Attempt to merge our remote branch into our local branch, if it's straightforward
output_lines += merge(root_loc, appname)
)
end

# If there is a git error we should let them know but carry on
Expand Down
2 changes: 1 addition & 1 deletion snippets/app_configuration.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
commodities: ["postgres-17", "elasticsearch5", "rabbitmq-4", "db2_community"]
commodities: ["postgres-17", "elasticsearch5", "rabbitmq-4", "db2_community", "floci"]
# Optional
expensive_startup:
- compose_service: name-of-service-from-compose-fragment
Expand Down
3 changes: 3 additions & 0 deletions snippets/floci-init-fragment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

aws s3 mb s3://test-bucket
Loading